如何告诉Cmake使用C89
因此,我最近决定从现在开始仅用于我的代码。我使用Cmake,我不确定如何告诉CMAKE使用C89。
根据网站上的信息,它说“(接受的值是98、99和11)”,这真的很奇怪,因为89不存在。
set (CMAKE_C_STANDARD 89)
此代码给了我一个错误。
真正奇怪的是,我在网上到处搜索的Ive,找不到任何人问这个问题。
有谁知道如何使用/(限制)仅在CMAKE中使用C89。
CMAKE文档说要使用
Supported values are:
90
C89/C90
此代码有效
set (CMAKE_C_STANDARD 90)
,但是我希望编译器仅使用C89而不是C90。
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.
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
SET(CMAKE_C_STANDARD 90)
使用C89。C89与C90相同,也称为ANSI C.
注意:更喜欢使用
set_target_properties(your_target属性C_STANDARD 90)
在目标上明确>在您的目标上明确,因此它不会影响其他目标。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 PROPERTIES C_STANDARD 90)
explicitly on your target, so it doesn't affect other targets.设置标准方式(CMAKE_C_STANDARD 90)
您可以使用以下内容:
target_compile_options(Hello Private -Std = C90)
这使您可以自由地向构建管道添加任何标志
standard way is set(CMAKE_C_STANDARD 90)
you can use the following:
target_compile_options(hello PRIVATE -std=c90)
this allows you the freedom to add any flag to the build pipeline