[Samba4] [FreeBSD] Conflicting definition of MACHINE macro

Timur I. Bakeyev timur at com.bat.ru
Mon Oct 8 11:45:15 GMT 2007


On Mon, Oct 08, 2007 at 12:03:31PM +0200, Jelmer Vernooij wrote:
> Am Montag, den 08.10.2007, 04:44 +0200 schrieb Timur I. Bakeyev:
> > Here is another problem. Compilation of the policy subsystem fails due
> > to the conflict of the system-wide definition of the MACHINE macro and
> > local MACHINE macro in the lib/policy/lex.l. In the recent SVN versions
> > this was fixed by renaming macro into CLASS_MACHINE, but usage of the
> > simple name macros like CLASS, DEFAULT, etc. is asking for troubles, as
> > these names are too common and may be used somewhere else. The best
> > practice here is to give more application specific names to the macros,
> > let's say prepend them with the POL_ prefix in this case.
> I'm not convinced this is necessary. These are enum values (basically
> defines), so they don't clutter the global symbol namespace. All they
> can conflict with are defines in the system headers and that doesn't
> appear to be a problem at the moment.

Oh, they DO! How did I find this out, you think? Local MACHINE definition
was conflicting with the <machine/param.h> which has:

#ifndef MACHINE
#define MACHINE         "i386"
#endif

And parse_adm.c, generated from .y file had:

...
/* Tokens.  */
#define CATEGORY 258
#define CLASS 259
#define USER 260
#define MACHINE 261
#define POLICY 262
...

Now MACHINE and USER are prepended with CLASS_ to work around this problem,
but I think it's safer to use local name space just to be on a safe side.

With regards,
Timur.


More information about the samba-technical mailing list