如何检查使用c99,而不是gnu99 [英] How to check that c99 is used, and not gnu99

查看:233
本文介绍了如何检查使用c99,而不是gnu99的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在编译期间添加一条警告消息来警告用户应该使用gnu99而不是c99(我使用的是匿名结构,并且它看起来在c99中根本不存在)。 b
$ b

我发现:

  #if __STDC_VERSION__> = 199901L 

但是这个测试对于c99和gnu99是正确的。



其中我可以使用预定义的宏吗?

解决方案

您可以检查自己:

  $ gcc -std = c99 -dM -E  - < / dev / null> c99.txt 
$ gcc -std = gnu99 -dM -E - < / dev / null> gnu99.txt
$ sdiff -s c99.txt gnu99.txt
#define __STRICT_ANSI__ 1<


I want to add a warning message during the compilation to warn the user it should use gnu99 instead of c99 (I am using anonymous struct, and it seems it doesn't exist at all in c99).

I found that:

#if __STDC_VERSION__ >= 199901L

but this test is true for c99 and gnu99.

Which predefined macro could I use?

解决方案

You can check for yourself:

$ gcc -std=c99 -dM -E - < /dev/null > c99.txt
$ gcc -std=gnu99 -dM -E - < /dev/null > gnu99.txt
$ sdiff -s c99.txt gnu99.txt
#define __STRICT_ANSI__ 1                     <

这篇关于如何检查使用c99,而不是gnu99的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆