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 5994759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:51:49+00:00 2026-05-22T23:51:49+00:00

According to this , the POSIX library does not include getopt.h . However, I

  • 0

According to this, the POSIX library does not include getopt.h. However, I found this in unistd.h:

#ifdef  __USE_POSIX2
/* Get definitions and prototypes for functions to process the
   arguments in ARGV (ARGC of them, minus the program name) for
   options given in OPTS.  */
# define __need_getopt
# include <getopt.h>
#endif

Does this mean that getopt.h is implicitly included when you include unistd.h? I mean, is the code above something I should expect from all implementations of the unistd header file, or is it just something that is in my particular version? Also, is the __USE_POSIX2 macro defined in POSIX.2 and onwards, or is it just for POSIX.2?

  • 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-22T23:51:49+00:00Added an answer on May 22, 2026 at 11:51 pm

    __USE_POSIX2 is an implementation detail of glibc; it corresponds to _POSIX_C_SOURCE >= 2 or _XOPEN_SOURCE being defined. These are also implied by _GNU_SOURCE, and are used implicitly unless strict ANSI mode is on. You are not supposed to define the __USE_ macros directly.

    Since it corresponds to a value >= 2, it does apply to later versions. See the feature_test_macros manpage for further details.

    Or, from the comments in features.h (the internal header – don’t include directly – that takes care of all this):

    /* These are defined by the user (or the compiler)
       to specify the desired environment:
    ...
       _POSIX_C_SOURCE  If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2;
                if >=199309L, add IEEE Std 1003.1b-1993;
                if >=199506L, add IEEE Std 1003.1c-1995;
                if >=200112L, all of IEEE 1003.1-2004
                if >=200809L, all of IEEE 1003.1-2008
       _XOPEN_SOURCE    Includes POSIX and XPG things.  Set to 500 if
                Single Unix conformance is wanted, to 600 for the
                sixth revision, to 700 for the seventh revision.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to this: http://www.xmlplease.com/xquery-xhtml XQuery does not have a standard way of setting the
According to this article rebasing is not necessary for .NET assemblies due to JIT
According to this CommonsWare example I managed to get my RelativeLayout subclass to be
Is errno on MSVC thread-safe? According to the answers in this question POSIX requires
According to this: Get current date/time in seconds var seconds = new Date().getTime() /
According to this answer , the intended way to include non-header-only parts of Boost
According to this question: Django on Google App Engine The easiest way to get
According to this SDK guide , unit-testing a Library project can be achieved by
According this MSDN article HttpApplication .EndRequest can be used to close or dispose of
According to this discussion , the iphone agreement says that it doesn't allow loading

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.