的C preprocessor工作 [英] Working of the C Preprocessor
本文介绍了的C preprocessor工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何下面这段code的工作,换句话说,什么是C preprocessor的算法?在所有的编译器做这个工作呢?
的#include<&stdio.h中GT;#定义B A
#定义一个170
诠释主(){
的printf(%i的,B);
返回0;
}
解决方案
在preprocessor刚刚替换 B
与 A
无论它发现它的程序,然后替换 A
与 170
这只是普通的文本替换。
作品上的gcc。
How does the following piece of code work, in other words what is the algorithm of the C preprocessor? Does this work on all compilers?
#include <stdio.h>
#define b a
#define a 170
int main() {
printf("%i", b);
return 0;
}
解决方案
The preprocessor just replaces b
with a
wherever it finds it in the program and then replaces a
with 170
It is just plain textual replacement.
Works on gcc.
这篇关于的C preprocessor工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文