Page 1 of 1

Setting up Compiler to support C18 standard

Posted: Sun Jul 26, 2020 1:25 am
by flexmcmurphy
Hello,

I am using Codelite 14.0.0

I want to write programs in the C programming language. I am trying to configure the compiler to enforce the C18 standard.
When I go in to this menu --> Workspace > Open Active Project Settings > Compiler> C Compiler Options

I don't see the option to set the C compiler options to compile against the C18 standard. I see a checkbox for "Enable ANSI C99 features" and another that says: "In C mode, support all ISO C90 programs."

Is it possible to make Codelite compile programs that are compatible with the C18 standard?

Cheers,

Flex

Re: Setting up Compiler to support C18 standard

Posted: Sun Jul 26, 2020 8:39 am
by eranif
CodeLite is an IDE. Just install the compiler you want and tell CodeLite to use it

Re: Setting up Compiler to support C18 standard

Posted: Sun Jul 26, 2020 11:07 am
by flexmcmurphy
Thank you for your response.

I am using gcc.exe (MinGW.org GCC Build-2) 9.2.0
I configured that compiler in Codelite: Menu > Workspace > Open Active Project Settings > General > Compiler

And it does compile C programs that I write. However I want to write different programs against different C standards.

When I write C++ programs there are check boxes in Workspace > Open Active Project Settings > Compiler> C Compiler Options... and I can use them to specify the language standard for the compiler to compile against such as:
Enable C++11 features
Enable C++14 features
Enable C++17 features

I don't see those kind of choices in there for the different standards in C such as: ANSI C, C90, C99, C11 and C18.
The closest thing I see is the option: "Enable ANSI C99 features."
So maybe the Codelite 14.0.0 IDE doesn't have a way to direct the compiler to the C18 standard? Or maybe you don't need to because it just will anyway? But then why can't I choose just C99 or C11 when Codelite lets you specify so carefully the different C++ standards?

Is it possible to configure Codelite to specifically use the ANSI C, C90 or C99 or C11 or C18 C language standards or maybe it is not possible because it is mostly intended to be used to write C++ programs?

Cheers,

flex

Re: Setting up Compiler to support C18 standard

Posted: Mon Jul 27, 2020 11:42 pm
by flexmcmurphy
Here is what I did to solve my problem.

As recommended in a helpful response to this thread 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

Cheers,

flex