Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to tell cmake to use c89

So I recently decided to make the switch to using c89 only for my code from now on. I use cmake and i’m not sure how to tell cmake to use c89.

Per a information on a website it says "(accepted values are 98, 99 and 11)", which is really strange because 89 isn’t there.

set (CMAKE_C_STANDARD 89)

This code gives me an error.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Whats really strange is that Ive searched everywhere on the web and couldn’t find anyone asking about this.

Does anyone know how to use/(restrict) to using only c89 in cmake.

the cmake document says to use

Supported values are:

90

C89/C90

This code works

set (CMAKE_C_STANDARD 90)

However I want the compiler to use just C89 not C90.

>Solution :

Use set(CMAKE_C_STANDARD 90) to use C89.

C89 is the same as C90, also called ANSI C.

Note: prefer to use set_target_properties(your_target C_STANDARD 90) explicitly on your target, so it doesn’t affect other targets.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading