man 7 feature_test_macros --> question

This is a discussion on man 7 feature_test_macros --> question within the Linux Programming forums, part of the Platform Specific Boards category; i cam across this: man 7 feature_test_macros in its info page i found the following;: acct(): _BSD_SOURCE || (_XOPEN_SOURCE && ...

  1. #1
    Registered User
    Join Date
    May 2012
    Posts
    34

    man 7 feature_test_macros --> question

    i cam across this:
    man 7 feature_test_macros
    in its info page i found the following;:
    acct(): _BSD_SOURCE || (_XOPEN_SOURCE && _XOPEN_SOURCE < 500)

    i have not understood why it has to be instead:


    acct(): _BSD_SOURCE || ( _XOPEN_SOURCE < 500)

    thank you in advance for the answer

  2. #2
    Registered User
    Join Date
    May 2012
    Posts
    34
    furthermore, for the feature test macro:
    acct(): _BSD_SOURCE || (_XOPEN_SOURCE && _XOPEN_SOURCE < 500)
    i need to write the following macro definitions:
    #define _BSD_SOURCE
    #define _XOPEN_SOURCE /* or any value < 500 */

    but for
    gethostname():
    Since glibc 2.12: _BSD_SOURCE || _XOPEN_SOURCE >= 500

    what macro definitions i have to write?



  3. #3
    Registered User
    Join Date
    May 2012
    Posts
    34
    and what value is this 500 ?

  4. #4
    Registered User
    Join Date
    May 2012
    Posts
    34
    how about also this one:
    getaddrinfo(), freeaddrinfo(), gai_strerror():
    _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _POSIX_SOURCE
    what macros do i need to use? how even i write the test _POSIX_C_SOURCE >= 1 ?

  5. #5
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    If you were looking at the man 7 page for feature test macros, why didn't you read the bit at the top about which macros should be defined when (and what their value should be, and what "500" means, and all the rest)?

    As to the first question, if _XOPEN_SOURCE is not defined, then it will be treated as 0 when compared to a number, which would unexpectedly make that condition true. Thus you check that it is defined, and then that it has a value less than 500.

  6. #6
    Registered User
    Join Date
    May 2012
    Posts
    34
    ok,
    then for this feature test macro:
    acct(): _BSD_SOURCE || (_XOPEN_SOURCE && _XOPEN_SOURCE < 500)
    i have answered the following:

    "
    As to the first question, if _XOPEN_SOURCE is not defined, then it will be treated as 0 when compared to a number, which would unexpectedly make that condition true. Thus you check that it is defined, and then that it has a value less than 500.
    "
    then it will be treated as 0 when compared to a number , the test is done in this condition: _XOPEN_SOURCE < 500 , then how do i test that it has a value less than 500 ?

  7. #7
    Registered User
    Join Date
    May 2012
    Posts
    34
    and for this test macro:
    this one:
    getaddrinfo(), freeaddrinfo(), gai_strerror():
    _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _POSIX_SOURCE

    the definitions are written for example in the following way?:::::
    #define _POSIX_C_SOURCE 2
    #define XOPEN_SOURCE
    #define _POSIX_SOURCE

  8. #8
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by tindala View Post
    ok,
    then for this feature test macro:
    acct(): _BSD_SOURCE || (_XOPEN_SOURCE && _XOPEN_SOURCE < 500)
    i have answered the following:

    "
    As to the first question, if _XOPEN_SOURCE is not defined, then it will be treated as 0 when compared to a number, which would unexpectedly make that condition true. Thus you check that it is defined, and then that it has a value less than 500.
    "
    then it will be treated as 0 when compared to a number , the test is done in this condition: _XOPEN_SOURCE < 500 , then how do i test that it has a value less than 500 ?
    You've got the test for testing that it has a value less than 500 already written in your post, so I don't know why you're asking.

    Also, unless you are planning to be writing the header files yourself, you don't do the test. Your job is to define the appropriate macro that matches what you want reality to be, and that's all you do. For example, if you want the compiler to act like it's System V, then you #define _SVID_SOURCE. If you want the compiler to match the C11 standard, you #define _ISOC11_SOURCE.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 03-23-2011, 09:00 AM
  2. *szString = things question/memory question
    By Jang in forum C Programming
    Replies: 3
    Last Post: 01-20-2011, 03:59 AM
  3. Newbish Question file reading question....
    By kas2002 in forum C Programming
    Replies: 23
    Last Post: 05-17-2007, 12:06 PM
  4. java question, how do you interpret this question.
    By indigo0086 in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 11-02-2006, 09:30 AM
  5. Self regiserting DLLs question and libraries question.
    By ApocalypticTime in forum Windows Programming
    Replies: 2
    Last Post: 03-22-2003, 01:02 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21