Re: How to obtain library name at compile/preprocessor time?



"babuyama" <babu.yama@xxxxxxxxx> wrote:
>Is there a way to obtain library name at compile/preprocessor time?
>>Assuming that the compilation unit, myfile.c is part of mylib.a, from
>myfile.c code at compile/preprocessor time, I would like to know that
>the library name is "mylib". I could not find an equivalent of
>__FUNCTION__, __FILE__ defines for getting the library name. Is there
>another way?

No. You invoke the compiler and generate an object file. How can the
compiler know if that object file will be used as-is, of first
inserted into a library A, or not used at all, or emailed to somebody
who will then insert it into library B, or ...

It is possible that development environment in which the file is
compiled as part of a "project" could define symbols identifying the
ultimate target. Any such mechanism would be unique to that
environment and not usable in generic C.

Since you use the ".a" suffix for a library I assume you are using a
variant of Unix/Linux. On these environments you can always define a
variable in the environment or in a make file, and pass it to the
compiler using "-Dxxxxx"

Roberto Waltman

[ Please reply to the group, ]
[ return address is invalid. ]
.