tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Use of feature test macros



    Date:        Sat, 2 Nov 2024 22:36:10 +0100
    From:        Roland Illig <roland.illig%gmx.de@localhost>
    Message-ID:  <852461a5-c852-40d0-a810-d377306b804d%gmx.de@localhost>

  | In the system headers, we use this pattern a lot:
  | > #if (_POSIX_C_SOURCE - 0 >= 200809L) || defined(_NETBSD_SOURCE)
  |
  | Are the parentheses around the first condition really necessary? If so,
  | for which cases?

Do they hurt?   Parens generally make it easier to read exprs like
this, within reason, almost never harder.

  | Is the "- 0" in the first expression really necessary? If so, for which
  | cases?

When _POSIX_C_SOURCE is undefined (or defined to nothing).
That is the standard idiom for testing all of these feature macros.

kre



Home | Main Index | Thread Index | Old Index