why does Erlang define macros reserved for the C compiler?

Matthias Lang matthias@REDACTED
Thu May 18 12:07:34 CEST 2006


Attempting to answer my own question.

A clue from Bengt and some googling gave me an answer for most of the
defines. At least some of them are GCC voodoo:

  http://gcc.gnu.org/onlinedocs/gcc-4.0.3/gcc/Variable-Attributes.html#index-g_t_0040code_007bdeprecated_007d-attribute-1792

Grepping for the __deprecated that started me wondering reveals that
it's only used in erts/emulator/beam/erl_alloc.h, to mark deprecated
functions.

Conclusion: the warning can be ignored. It could be eliminated by
testing for an existing definition before redefining it.

I still don't know why the __SYS_H__ is there. For header files in the
C library, it makes perfect sense to be using names with leading
underscores---they're reserved, so you can be sure you don't screw up
the user's namespace. Using it in Erlang, on the other hand, makes
no sense. It's probably just historical cruft.

Matthias

--------------------

Matthias Lang writes:
 > 
 > I'm looking at erts/emulator/beam/sys.h.
 > 
 > When building Erlang, the compiler prints out a bunch of warnings
 > about __deprecated being redefined. This seems to be C99 7.1.3 in
 > action, i.e. identifiers starting with _ are reserved for the C
 > compiler and C library.
 > 
 > The defines in that file with leading underscores:
 > 
 >   __SYS_H__
 >   _DOTS_
 >   _VOID_
 >   __noreturn
 >   __deprecated
 >   _POSIX_SOURCE
 >   _XOPEN_SOURCE
 > 
 > Some of these, e.g. __deprecated, look like some sort of GCC
 > voodoo. Does anybody know more?
 > 
 > Matthias



More information about the erlang-questions mailing list