From: peter on
Hi all
If I use #define in a shared library, that #define cannot be
shared among every process? (that mean it is not shared)?
example:

#define isalnum(c) (_ctype[(c) + 1] & (_IS_DIG | _IS_UPP | _IS_LOW))

If a shared library has isalnum() as above, is it still a *shared*
library?


thanks
from Peter (cmk128(a)hotmail.com)
From: Alexei A. Frounze on
On May 4, 3:34 am, peter <cmk...(a)gmail.com> wrote:
> Hi all
>     If I use #define in a shared library, that #define cannot be
> shared among every process? (that mean it is not shared)?
> example:
>
> #define isalnum(c)      (_ctype[(c) + 1] & (_IS_DIG | _IS_UPP | _IS_LOW))
>
> If a shared library has isalnum() as above, is it still a *shared*
> library?
>
> thanks
> from Peter (cmk...(a)hotmail.com)

C/C++ macros can be shared by means of inclusion of the files where
they are defined. Macros can't be referenced, they have no name, so,
once they are in compiled code (e.g. in a library), you can't access
them in any way other than accessing the functions where they were
used.

Alex
From: Alexei A. Frounze on
On May 4, 7:37 am, "Alexei A. Frounze" <alexfrun...(a)gmail.com> wrote:
> On May 4, 3:34 am, peter <cmk...(a)gmail.com> wrote:
>
> > Hi all
> >     If I use #define in a shared library, that #define cannot be
> > shared among every process? (that mean it is not shared)?
> > example:
>
> > #define isalnum(c)      (_ctype[(c) + 1] & (_IS_DIG | _IS_UPP | _IS_LOW))
>
> > If a shared library has isalnum() as above, is it still a *shared*
> > library?
>
> > thanks
> > from Peter (cmk...(a)hotmail.com)
>
> C/C++ macros can be shared by means of inclusion of the files where
> they are defined. Macros can't be referenced, they have no name, so,
> once they are in compiled code (e.g. in a library), you can't access
> them in any way other than accessing the functions where they were
> used.
>
> Alex

To elaborate, macros aren't program objects such as global variables
or functions. Macros exist only at the source level, they are merely a
means of text substitution in the source code. They have no associated
storage other than the code they turn into at compile time. And that's
why they have no names at the object/binary level. It's the same with
numbers in C/C++, You can't take an address of, say, number 1 (&1 is
invalid).

Alex