GCC-2——杂项汇总
1. __builtin_constant_p
它是GCC的内建函数,用于判断一个值是否为编译时常数,如果参数是常数,函数返回 1,否则返回 0。
#include <stdio.h> #define MAX 10 //built in constant int global = 10; //non built in constant int * const p = NULL; //non built in constant int test_func() //non built in constant { return 0; } void main() { if (__builtin_constant_p(p)) { printf("built in constant\n"); } else { printf("non built in constant\n"); } }
posted on 2022-11-26 23:19 Hello-World3 阅读(73) 评论(0) 编辑 收藏 举报