如何编写灵活编译的程序?

时间:2011-03-04 18:06:36

标签: compilation preprocessor

如何编写灵活编译的程序?。

#include "stdio.h"
void samplef(int d)
{
   printf(....); // if d=1 no compile this line
   printf(....); // else compile this line
}

3 个答案:

答案 0 :(得分:0)

我不确定你在问什么,但听起来不太可能。

编译器在编译程序时不知道程序运行时d的值是什么。

我怀疑你可能误解了“编译”这个词......?

答案 1 :(得分:0)

预处理。您正在寻找preprocessing

答案 2 :(得分:0)

您可以使用预处理器执行此类操作,但始终使用定义,而不是使用变量求值,因为编译器在编译时不知道该值。