69,382
社区成员
发帖
与我相关
我的任务
分享
#ifdef __STDC_LIB_EXT1__
// output something
#endif
注意我说的是__STDC_LIB_EXT1__,不是你定义的__STDC_WANT_LIB_EXT1__。前者由库决定是否定义,后者是在库定义了前者的前提下由用户定义以便使用strnlen_s之类的函数。[/quote]
#include<stdio.h>
int main(void)
{
#if defined _STDC_LIB_EXT1_
printf("Optional functions are defined.\n");
#else
printf("Optional functions are not defined.\n");
#endif
return 0;
}
代码如上,在centos下是可以支持。
会输出Optional functions are defined[/quote]
那就不知道了,你gcc用的是什么版本?我用最新版的gcc运行输出的是not defined,编译选项只是多了警告选项,应该不会有影响:
运行结果#ifdef __STDC_LIB_EXT1__
// output something
#endif
注意我说的是__STDC_LIB_EXT1__,不是你定义的__STDC_WANT_LIB_EXT1__。前者由库决定是否定义,后者是在库定义了前者的前提下由用户定义以便使用strnlen_s之类的函数。[/quote]
Dev c++是不支持可选函数,我只是截的dev c++的图,因为他们的错误提示都是一样的#ifdef __STDC_LIB_EXT1__
// output something
#endif
注意我说的是__STDC_LIB_EXT1__,不是你定义的__STDC_WANT_LIB_EXT1__。前者由库决定是否定义,后者是在库定义了前者的前提下由用户定义以便使用strnlen_s之类的函数。[/quote]
#include<stdio.h>
int main(void)
{
#if defined _STDC_LIB_EXT1_
printf("Optional functions are defined.\n");
#else
printf("Optional functions are not defined.\n");
#endif
return 0;
}
代码如上,在centos下是可以支持。
会输出Optional functions are defined