gcc -std=c89 -xc++ undefines __cplusplus

Danny Smith danny_r_smith_2001@yahoo.co.nz
Fri Aug 23 21:00:00 GMT 2002


Specifying -std=c89 with -xc++ undefines __cplusplus, but
leaves __GNUG__ defined.

In contrast, when -ansi is specified with -xc++, __cplusplus
_is_ defined

Is this intended behaviour?  It tweaks a parse error for me
when using __attribute__((unused)), eg:

#ifdef __GNUC__
# ifdef __cplusplus /* __GNUG__ */
#  define _ARGS_UNUSED(x)
# else
#  define _ARGS_UNUSED(x) x __attribute__((unused))
# endif 
#else /* !__GNUC__ */
# define _ARGS_UNUSED(x) x
#endif

static
__inline__
int
my_fwide(FILE* _ARGS_UNUSED(stream), int _ARGS_UNUSED(mode))
  {return -1;} /* limited to byte orientation */ 

This compiles okay with -xc++ -ansi, but not -xc++ -std=c99
The obvious workaround is to use __GNUG__ as the guard
(or don't set C std in C++)

Danny

http://digital.yahoo.com.au - Yahoo! Digital How To
- Get the best out of your PC!



More information about the Gcc mailing list