Re: Query:api problems!



In article <f2a55c$2gu$1@xxxxxxxxxxxxx>, Jack Dowson <jckdwsn@xxxxxxx> wrote:

I'm new to c.I am wondering who can tell me how to use API in my c program.

API is usually an abbreviation for "Application Programmer Interface".
For any packaged routines, the program's API is the official documented
methods of getting the routines to do whatever they are supposed to.

If you have a routine that has an API, then there is nothing
special you need to do in your C program to use it. You just
#include whatever header files the API documents that it requires,
and you make the calls to the routines in the manner documented.


The rest of this discussion involves practical development matters
that the C standard leaves up to the implementation; your
implementation might have a wildly different way of handling these
matters (especially if you are using one of the "visual" compilers.)
As far as the C standard goes, there are very few rules beyond
that the implementation must give you -some- way to link different
source files together. There is no right or wrong way in the standards
for most of these points -- and that means that to find out the
right way to do these things for your particular system, you need
to ask in a newsgroup that deals with your operating system.


You may need to tell the compiler where to find the include files
for the package. The method of doing that depends on which compiler
you are using. In -most- compilers that work from the command line,
you would add an option that started with a dash followed by
an upper-case I followed by the name of the directory to look in.
For example, -I/opt/gnu/include would (usually) tell the
compiler to look for include files in the directory /opt/gnu/include

You will probably also need to tell your compiler to link
the package into your executable. The method of doing that
depends on which compiler you are using. In -most- compilers
that work from the command line, you would add an option
that started with dash followed by lower-case L followed
by a representation of the name of the library, such as
-lcrypto . The exact name you would use after the -l depends
on your compiler: fairly common is that library names
of the form libXXXX.something would become the option -lXXXX
(i.e., remove the 'lib' prefix and any suffixes.) You may also
have to tell the compiler where to find the library; fairly
common in command-line compilers is to use an option that starts
with a dash followed by an upper-case L followed by the directory
to look in; e.g., -L/opt/gnu/lib32 -lcrypto to look for
libcrypto.something in the directory /opt/gnu/lib32
--
Okay, buzzwords only. Two syllables, tops. -- Laurie Anderson
.



Relevant Pages

  • Re: win32ada coverage
    ... I'm creating my own package to include those APIs for my ... expanding win32Ada to include these new routines can be as easy as ... to use the existing win32Ada as a guide to aid you in adding those extra API ...
    (comp.lang.ada)
  • Re: Freeware download corrupt (?)
    ... > a list of all functions in a package that fall in that category. ... > conflict with a function of that name in a future version of the CRTL. ... > But the compiler doesn't do that, so for now we're on our own. ... I create a package with a routine in it called "highwater". ...
    (comp.os.vms)
  • Re: PL/I, COBOL, Advantages, Equivalence, et al
    ... SPARK will allow a variable to have a value that conforms ... might be that a package somewhere will look like this ... An Ada compiler may issue a warning; ... LC> Ada/SPARK support a boolean type? ...
    (comp.lang.pl1)
  • managing header files
    ... while in the .h files the external declarations showed no arguments. ... Apparently that was the reason the compiler wasn't catching errors of the ... wrong number of arguments when routines were called from other files. ... Then I went through the all the header files ...
    (comp.lang.c.moderated)
  • Re: object system...
    ... [A C compiler cannot put a loop control variable in a register without ... and then later may assemble them into ... this whole API may be modified and redirected (in ... functionality it exports, but instead redirects it to the particular library ...
    (comp.object)