libtool
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Library coding standards question


From: Tim Mooney
Subject: Re: Library coding standards question
Date: Sat, 23 Feb 2002 15:05:57 -0600 (CST)

In regard to: Library coding standards question, jks said (at 12:42am on...:

>"Choose a name prefix for the library, more than two characters long. All
>external function and variable names should start with this prefix. In
>addition, there should only be one of these [one name prefix, one external
>function, one variable name, or one of something else?] in any given library
>member [what is the meaning of "library member" in this context?]. This
>usually means putting each one [one what?] in a separate source file."

A "name prefix" just means that for C libraries, all your visible symbols
should start with some kind of prefix, i.e. your API shouldn't have
functions like

        read()
        write()

etc., but instead use

        jkslib_read()
        jkslib_write()

etc.  That's because of the problem with namespace pollution/collision in
C.  This isn't as much of an issue for libraries in some other languages,
but it's still worth considering.

A member is generally one object file.  The guidelines are saying that if
your `libjks.a' or `libjks.so' or whatever has multiple members *and*
those members have multiple name prefixes (e.g. you have externally
visible symbols jkslib_read() and jkslib_write() to read and write your
new "JKS" video format, and you also have mpeg4_read() and mpeg4_write()
to handle MPEG4 video format), then the externally visible functions
should be in separate members:

        cc -o jks.o -c jks.c
        cc -o mpeg4.o -c mpeg4.c
        ar -crv libjks.a jks.o mpeg4.o
        nm -B libjks.a
        jks.o:
    0x00000000000080  T  jkslib_read
    0x00000000000d90  T  jkslib_write
        mpeg4.o:
    0x000000000001f0  T mpeg4_read
    0x00000000000b40  T mpeg4_write


That doesn't illustrate the use of libtool, but it does illustrate what
the text you've quoted is talking about.

Tim
-- 
Tim Mooney                              address@hidden
Information Technology Services         (701) 231-1076 (Voice)
Room 242-J6, IACC Building              (701) 231-8541 (Fax)
North Dakota State University, Fargo, ND 58105-5164




reply via email to

[Prev in Thread] Current Thread [Next in Thread]