GCC 12 Adds Support For New #elifdef #elifndef Directives

Written by Michael Larabel in GNU on 12 May 2021 at 05:52 AM EDT. 28 Comments
GNU
With C2X and potentially a future version of C++, there is finally the #elifdef and #elifndef directives. The GNU Compiler Collection is preparing its support.

There has long been #ifdef, #else, #elif and similar directives for controlling conditional compilation in C/C++. While there has been #ifdef, until the upcoming C2X there hasn't been #elifdef for else if defined or #elifndef for else if not defined... Short of pairing "#elif defined()" or so. With C2X the #elifdef and #elifndef pre-processor directives are finally there and it's being looked at for C++ as well.

There is this blog post for those interested in that it was actually some what of a battle earlier this year getting the feature accepted during the last C meeting.

Merged yesterday to GCC 12 was the initial work on #elifdef and #elifndef. For the time being the directives are supported with just the c2x/gnu2x language targeting while waiting to see if/when they will be accepted for C++.

LLVM Clang also has pending patches for supporting these convenient directives as well.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week