如何告诉Cmake使用C89

发布于 2025-02-11 03:25:59 字数 427 浏览 1 评论 0原文

因此,我最近决定从现在开始仅用于我的代码。我使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

私藏温柔 2025-02-18 03:25:59

使用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.

顾忌 2025-02-18 03:25:59

设置标准方式(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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文