文章目录
解释
/stdlib/isomac.c
这是一个精心设计的程序,用来检查系统头文件中的“非法宏定义”。 什么是非法的宏定义:
- 不是出自实现域内的,例如,没有以下划线开始的
- 不是标准定义的宏。
- 例外情况,就是以E开头的,可能是errno.h里的定义。
- 例外情况,以_MAX 结尾,参考下面的 前缀后缀总结。
In a compliant implementation no other macros can be defined, because you could write strictly conforming programs that may fail to compile due to syntax errors: suppose <stdio.h> defines PIPE_BUF, then the conforming
#include <assert.h>
#include <stdio.h> <- or where the bogus macro is defined
#include <string.h>
#define STR(x) #x
#define XSTR(x) STR(x)
int main (void)
{
int PIPE_BUF = 0; 、、、如果真有问题,也是在这一行现有编译错误。目前的版本是这样
assert (strcmp ("PIPE_BUF", XSTR (PIPE_BUF)) == 0); 、、、、 这个例子有点老了,现在stdio.h里没有了PIPE_BUF
return 0;
}
is expected to compile and meet the assertion. If it does not, your compiler compiles some other language than Standard C.
REQUIREMENTS:
This program calls gcc to get the list of defined macros. If you
don't have gcc you're probably out of luck unless your compiler or
preprocessor has something similar to gcc's -dM option. Tune
PRINT_MACROS in this case. This program assumes headers are found
under /usr/include and that there is a writable /tmp directory.
Tune SYSTEM_INCLUDE if your system differs.
#define BROKEN_SYSTEM if system(NULL) bombs -- one more violation
of ISO C, by the way.
OUTPUT:
Each header file name is printed, followed by illegal macro names
and their definition. For the above example, you would see
...
/usr/include/stdio.h
#define PIPE_BUF 5120
...
If your implementation does not yet incorporate Amendment 1 you will see messages about iso646.h, wctype.h and wchar.h not being found. */