Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 265227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:45:06+00:00 2026-05-11T22:45:06+00:00

On Solaris, in order to get the msg_control field in struct msghdr and have

  • 0

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
  1. Should I do it this way?
  2. Do I need to define them in all source files, or bad things may happen?
  3. Is there a list of these things somewhere?

This is related to this question.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T22:45:06+00:00Added an answer on May 11, 2026 at 10:45 pm

    man -k XPG4 reveals that there is a standards(5) man page, which lists the feature test macros and library linking info for various standards, including the following:

    X/Open CAE
    To build or compile an application that conforms to one of
    the X/Open CAE specifications, use the following guidelines.
    Applications need not set the POSIX feature test macros if
    they require both CAE and POSIX functionality.

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

    Grepping through /usr/include for _XOPEN_SOURCE turns more information in /usr/include/sys/feature_tests.h:

    application writers wishing to use any functions specified as X/Open UNIX Extension must define _XOPEN_SOURCE and _XOPEN_SOURCE_EXTENDED=1. The Sun internal macro _XPG4_2 should not be used in its place as unexpected results may occur.

    So defining _XPG4_2 yourself 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:

    cc -D_XOPEN_SOURCE=1 -D_XOPEN_SOURCE_EXTENDED=1
    

    If you’re using make, you should be able to do this by adding the -D parameters to the CFLAGS variable:

    CFLAGS += -D_XOPEN_SOURCE=1 -D_XOPEN_SOURCE_EXTENDED=1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have applications on Solaris 10 servers that generate text logfiles. We need to
I have to implement some mechanism in C on SOLARIS 9 SPARC in order
On Solaris 9 and 10, both x86 and Sparc, we have a process that
I have a Solaris daemon written in Java6. Clients can connect to it using
I'm using Solaris 10, ksh . Whenever I do a ./configure , I get
I have a Solaris sparc machine and when i build my programs, it generates
I am using Solaris. I have to log into sql plus and run some
On a Solaris 5.8 machine, I have the following code: [non-working code] char *buf;
I have a Solaris sparc (64-bit) server, which has 16 GB of memory. There
On Solaris, is there a command that I can run to get the MAC

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.