![]() |
CITS2002 Systems Programming |
← prev | next → | ![]() |
![]() |
|||
Your C compiler's version and default language standardNow a decade since C11 was released, and contempory compilers, such as gcc and clang, support all C11 features (on hosted platforms), and support requests for backward compatability from earlier standards (cc -std=cXX ...).While easy to determine the version of a compiler being used:
macOS-prompt> cc --version
Ubuntu-prompt> cc --version compiler front-ends support many languages and versions, so knowing the compiler's version is not much use. Instead, we need to know how our source code is being compiled, at compile time. We can test against the __STDC_VERSION__ preprocessor token, and then (possibly) compile different code/functions in our program:
This assists our goal of portable programming by ensuring that a program's required features are supported by the local compiler, and its default compilation arguments.
CITS2002 Systems Programming, Lecture 22, p3, 16th October 2023.
|