On Solaris, in order to get the msg_control field in struct msghdr and have IPV6_TCLASS I seem to need to define _XPG4_2 and __EXTENSIONS__.
It seems to work if I just define these to 1 before including anything:
#if defined (__SVR4) && defined (__sun)
# define _XPG4_2 1
# define __EXTENSIONS__ 1
#endif
- Should I do it this way?
- Do I need to define them in all source files, or bad things may happen?
- Is there a list of these things somewhere?
This is related to this question.
man -k XPG4reveals that there is astandards(5)man page, which lists the feature test macros and library linking info for various standards, including the following:Grepping through
/usr/includefor_XOPEN_SOURCEturns more information in/usr/include/sys/feature_tests.h:So defining
_XPG4_2yourself is not the way to do it.If any structure definitions depend on these macros, you would definitely be better off defining them in all translation units. The easiest way to do that is to specify them on the compiler command line:
If you’re using
make, you should be able to do this by adding the-Dparameters to theCFLAGSvariable: