How to Check Your C Version?

5/5 - (2 votes)

Different compilers, such as GCC and Microsoft Visual Studio, have specific methods for identifying the C version being used. Depending on your operating system, you might need to use different flags or commands to check the version.

Throughout this article, we’ll provide examples and insights to help you find the C version of your compiler with ease.


Identifying C Version

Checking Compiler Version

If you are using gcc, a popular C compiler, checking the compiler version is simple. Just run the following command:

gcc --version

This will output the GCC version being used on your system. πŸŽ‰ However, do note that this is not the version of the C language, just the compiler’s version. To get the C language version, proceed to the next sub-section.

Identifying C Standard

The C language has evolved through various ISO standards, such as C89/C90, C99, C11, C17, and C18. You can identify the version of the C language your compiler supports by checking the __STDC_VERSION__ macro.

Use a simple C program like the one below to print the value of __STDC_VERSION__:

#include <stdio.h>

int main() {
    printf("%ld\n", __STDC_VERSION__);
    return 0;

Compile and run the program to display the C language version in use. For instance, you might see:

  • 201112L for C11 πŸ˜ƒ
  • 199901L for C99 πŸš€
  • 199409L for C89/C90 with amendment 1 (commonly known as C95) πŸ› οΈ

If the __STDC_VERSION__ macro is undefined or not available in your environment, it usually implies an older version (C89/C90) of the language.

Keep in mind that your compiler might support multiple versions of C. To enforce a specific version, you can pass -std options to the gcc compiler:

gcc -std=c99 source_file.c -o output_file

This command enforces the C99 standard, but you can replace c99 with the desired version (c89, c90, c11, c17, or c18).

Using Compiler Flags

Setting Language Standard

When working with C++, it’s essential to specify the language standard you want to use.

πŸ’‘ Recommended: How to Check C++ Version

Different standards, like C++11, C++14, C++17, and C++20, introduce new features and improvements to the language. To set the language standard while compiling, use the -std flag followed by the desired version.

Here are some examples:

  • For C++11: g++ -std=c++11 myfile.cpp -o myfile
  • For C++14: g++ -std=c++14 myfile.cpp -o myfile
  • For C++17: g++ -std=c++17 myfile.cpp -o myfile
  • For C++20: g++ -std=c++20 myfile.cpp -o myfile

πŸ’‘ Remember to replace myfile.cpp and myfile with your source file and output file, respectively.

Default Language Standard

If you don’t specify a language standard, the compiler will use a default one. The default standard might differ between compilers and their versions. To determine the default language standard used by your compiler, you can try examining the preprocessor macros.

For GCC, create a C++ file (e.g., check_version.cpp) with the following content:

#include <iostream>
int main() {
#if __cplusplus == 201103L
    std::cout << "C++11\n";
#elif __cplusplus == 201402L
    std::cout << "C++14\n";
#elif __cplusplus == 201703L
    std::cout << "C++17\n";
#elif __cplusplus >= 202002L
    std::cout << "C++20 or later\n";
    std::cout << "Unknown version\n";
    return 0;

Then, compile and run the file without specifying any language standard:

g++ check_version.cpp -o check_version

The output will display the default language standard used by your compiler.

πŸŽ“ Keep in mind that knowing your compiler’s default language standard is essential, especially when working on projects that don’t explicitly set a specific standard.

Windows Environments

Microsoft Visual Studio

Microsoft Visual Studio is a powerful IDE that supports various programming languages such as C, C++, C#, and Java.

To check the version of the C compiler used in Visual Studio, follow these steps:

  1. Open your C project in Visual Studio.
  2. From the top menu, go to Project and select Properties.
  3. In the Properties window, navigate to Configuration Properties > C/C++ > Language.
  4. Find the C Language Standard option, and check the selected standard in the dropdown menu. πŸ˜ƒ

Visual Studio also provides the Microsoft Visual C++ Redistributable packages which are runtime components required to run applications developed using Visual Studio. You can find the installed version on your system by:

  • Pressing the Windows key + R, type appwiz.cpl, and press Enter.
  • Look for Microsoft Visual C++ YYYY Redistributable, where YYYY indicates the version year, in the Programs and Features list.

Windows Terminal

To check the C language version currently supported by your compiler (e.g., GCC or Clang) in the Windows Terminal, use the following command:

gcc -dM -E - < /dev/null | grep "__STDC_"

Replace gcc with your compiler’s command, such as clang for the Clang compiler. The command will output information about the supported C standard:

  • If the output shows __STDC__ defined to be 1, your compiler supports C89 (also called ANSI C) or ISO C90. πŸŽ‰
  • More recent standards like C99 or C11 will define additional macros such as __STDC_VERSION__ with values indicating the standard version.

For instance, if you see __STDC_VERSION__ defined to 199901L, it indicates your compiler supports the C99 standard. Similarly, a value of 201112L represents support for C11.

Linux Environments

In a Linux environment, you can easily determine the C language version being used by leveraging the power of the command line. πŸš€ For instance, when using the GCC (GNU Compiler Collection), you can check its version using the following command in your terminal:

gcc --version

This instruction will output the GCC version, and you can then consult the official documentation to map it to the appropriate C standard.

For example, when working with C code on Linux, you may use the following steps:

  1. Write your C code: Create a file named myfile.c containing the C source code you intend to work with.
  2. Compile the C code: Run the gcc command to compile your code: gcc myfile.c -o myfile
  3. Execute the compiled program: Execute the compiled binary by running: ./myfile

Through these simple steps, you can write, compile, and execute C programs in a Linux environment.

Compiler Help and Updates

First, you can determine your installed compiler’s version by executing the following command in your terminal:

gcc -v

This command will output information about the GCC compiler, including the version number and default language standard.

For example, you may see something like:

gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)

πŸ”§ Keep in mind that your output may differ based on your OS and installed compiler version.

If you find that you have an older version of gcc installed and want to update it, most Linux distributions offer an easy way to do so. For example, on Ubuntu, you can use the following command to update your gcc compiler:

sudo apt update && sudo apt upgrade

πŸ“š On Windows, you can install the latest version of gcc using MinGW or using the Windows Subsystem for Linux (WSL).

Once you have the latest version of your compiler installed, you can check the C language version it supports by using the -std flag when compiling your code. For example:

gcc -std=c99 myfile.c -o myfile

This command compiles myfile.c using the C99 standard. GCC and other compilers support various C standards, like c89, c99, c11, and c18.

πŸ’‘ For additional help with compiler options, you can use:

gcc --help

This command will provide a summary of the available options for your gcc compiler, allowing you to reference the supported features and versions of the C language.

πŸ’‘ Recommended: C Developer — Income and Opportunity

Security and Dependencies

When working with C and its various versions, it’s crucial to be aware of the security risks and dependencies involved. Ensuring your application’s security is essential, especially when using external libraries or DLLs (Dynamic Link Libraries) πŸ“š.

One way to mitigate security risks is by making use of Dependency Scanning tools. These tools can automatically find vulnerabilities in your software dependencies during development and testing.

For example, if you’re using an external (open source) library known to be vulnerable, dependency scanning can alert you to it🚨. There are several tools available for checking the security risk of open-source dependencies, which can help you stay ahead of potential issues.

In the context of Visual Studio, the Visual Studio 2010 Redistributable Package is a set of runtime components required for running applications created in Visual Studio πŸ”§. This package is often necessary when working with different versions of C.

It is important to ensure that you’re using the latest version of the redistributable package when working with the most recent version of C for added security benefits πŸ”’. If you’re unsure about the version of the C language you’re using, you can specify the version with the -std command line option as mentioned here.

Constants and Macros for C Versions

In C programming, constants and macros play a crucial role in identifying the version of the C language your compiler supports. These preprocessor directives help manage the compilation process and provide valuable information about the compiler and environment settings. Let’s explore some commonly used constants and macros that help identify the C version. 😊

πŸ’‘ Important: The primary constant for identifying the C version is __STDC_VERSION__. This macro holds a long integer value that represents the year and month of the C language standard version. For example, the value 199901L represents the C99 standard, and the value 201112L represents the C11 standard.

You can retrieve this value using a simple code snippet:

#include <stdio.h>
int main() {
  printf("__STDC_VERSION__: %ld\n", __STDC_VERSION__);
  return 0;

If you are using the GCC compiler, you can check the predefined macros with the following command:

gcc -dM -E - < /dev/null

This command reveals various predefined macros, including the __STDC_VERSION__ constant if your compiler supports one of the newer C language standards. πŸš€

In addition to the standard version constants, there are various feature test macros like _GNU_SOURCE, _BSD_SOURCE, and _POSIX_C_SOURCE. These macros can be defined by the program being compiled and influence the availability of specific functions, system libraries, or other compiler features. Defining these macros can help you ensure portability and compatibility across different platforms and environments.

#define _GNU_SOURCE
#include <stdio.h>

Frequently Asked Questions

What is the current version of the C programming language?

The current version of the C programming language is C17, which was released in June 2018. The C17 standard is also known as C18 due to the ISO publication date being in 2018. C standards are developed and maintained by the International Organization for Standardization (ISO)πŸ“š.

How can I determine my C compiler’s version?

You can determine your C compiler’s version by running a specific command in your command-line interface. For example, if you are using GCC (GNU Compiler Collection), you can run gcc --version to see the current version installed on your systemπŸ’».

What command checks the C version for GCC?

To check the C version for GCC, you can use the following command:

gcc -std=cVERSION -E -x c - < /dev/null

Replace VERSION with the C standard you want to test, such as c11, c17, or c18. If the command doesn’t produce any error messages, your GCC compiler supports that C versionπŸ‘.

How do I find out the C version in use on Linux?

On Linux, you can find the C version in use by checking your installed compiler’s documentation or typing the following command in your terminal:

gcc --version

This command will display the GCC version, which you can then cross-reference with the specific C version your compiler supports🐧.

Is there a preprocessor macro to determine the C version?

Yes, you can use the __STDC_VERSION__ preprocessor macro to determine the C version. This macro is defined by the C standard and indicates the version of the C language supported by the compiler. For example, for C99, the value of __STDC_VERSION__ is 199901L. You can check this value in your C code using the #if and #endif preprocessor directivesπŸ”.

What are the differences between various C language versions?

Each version of the C language introduces new features, improvements, and sometimes changes to the syntax or semantics. Some notable differences between C versions include:

  • C89: Initial standard by ANSI, basic features with no inline functions or variable-length arrays.
  • C99: Introduced new features like inline functions, variable-length arrays, and single-line comments.
  • C11: Added support for multithreading, atomic operations, and improved Unicode support.
  • C17/C18: Introduced mainly bug fixes, clarifications, and improved compatibilityπŸ”„.

To get a detailed understanding of the differences and new features introduced in each C version, you should refer to the official ISO specifications or other in-depth resources.