How does _XPG4_2 and others that work on Solaris work?

On Solaris, in order to get the msg_control field in struct msghdr and have IPV6_TCLASS, I think I need to define _XPG4_2 and __EXTENSIONS __.

It seems to work if I just define them 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 can bad things happen?
  • Is there a list of these things somewhere?

This is related to this issue .

+3
source share
1 answer

man -k XPG4 , standards(5), , :

X/Open CAE       ,       X/Open CAE, .       POSIX,       CAE, POSIX.

 SUS (XPG4v2)
       The application must define _XOPEN_SOURCE with a value
       other    than    500    (preferably    1)    and   set
       _XOPEN_SOURCE_EXTENDED=1.

Grepping /usr/include _XOPEN_SOURCE /usr/include/sys/feature_tests.h:

, , X/Open UNIX, _XOPEN_SOURCE _XOPEN_SOURCE_EXTENDED=1. Sun _XPG4_2 , .

, _XPG4_2 - .

- , . - :

cc -D_XOPEN_SOURCE=1 -D_XOPEN_SOURCE_EXTENDED=1

make, , -D CFLAGS:

CFLAGS += -D_XOPEN_SOURCE=1 -D_XOPEN_SOURCE_EXTENDED=1
+8

Source: https://habr.com/ru/post/1711114/


All Articles