开发者

Can you please explain this piece of code? [closed]

It's difficult to tell 开发者_JAVA技巧what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 12 years ago.
#include <stdio.h>
#include CONST15
#define CONST2 CONST2*CONST1
#define CONST3 CONST2+CONST2
int main(int argc,char**argv)
{
printf("%\n",CONST3);
}


First, preprocessing, which is the step that expands #defined'd symbols, happens before actual compilation.

Then, I don't think such a symbol can be recursive, but it can be replaced. So if that is the full program, and assuming <stido.h> doesn't define a CONST15 or a CONST2, you won't get any reasonable results. My compiler gives an error on the #include line that doesn't specify what to include.

However, you might compile it defining some symbols at compile time, such as:

gcc -DCONST15='"math.h"' -DCONST1=3 -DCONST2=5 foo.c

This would give the #include something (harmless) to work with, and provide a value for CONST1 and CONST2.

Then the first define would set CONST2 to 3*5 (just as that, not 15), and then the second define would set CONST3 to 3*5+3*5.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜