How to configure Codelite to compile a C program against C17/C18 standard

1.7k Views Asked by At

I am using Codelite 14.0.0 with the gcc.exe (MinGW.org GCC Build-2) 9.2.0 compiler.

When I go to Menu > Workspace > Open Active Project Settings > Compiler> C Compiler Options... I can't see any option to make the compiler compile my C programs against the (latest) C18 standard.

Is it possible to do this in Codelite?

2

There are 2 best solutions below

0
On

You should probably add the -std=c18 compiler flag. Note that it's the same as the -std=c17 flag as it's actually the 2017 standard that was published in 2018.

Also note a newer version of MinGW GCC is available (10.2.0). A standalone build is available at http://winlibs.com/

0
On

As recommended I downloaded the latest version of GCC from http://winlibs.com/

Then I added that GCC compiler to Codelite.. Menu > Settings > Build Settings > Press the + icon to add a compiler and navigate to the bin directory of the MinGW GCC [e.g: C:\mingw64\bin] then give it a name, e.g: GCC 10.2.0

To tell Codelite to tell the GCC compiler to compile C programs against the (latest) C18 standard...

The option to specify C18 is not listed in Menu > Workspace > Open Active Project Settings > Compiler> C Compiler Options.

You can tell the GCC compiler in Codelite to use the C18 standard for a specific Project by going to Menu > Workspace > Open Active Project Settings > Compiler> C Compiler Options then click on the little ellipsis button then type in -std=c18 in the "Enter other options" textbox.

Alternatively you can add this to the list of "C Compiler Options"… Menu > Settings > Build Settings > Compiler Options > New. Then for "Switch" type: -std=c18 and for "Help" type: Enable C18 features.

As explained in the Language Standards Supported by GCC and from testing I note that to enforce the gcc compiler to use the C18 standard you can specify -std=c11 OR -std=c17 OR -std=c18 as a parameter to gcc.exe