我有3个文件:预处理器指令define和ifdef不按我想象的那样工作?
的main.c
#include <stdio.h>
#include <stdlib.h>
#include "test.h"
#define DEBUG
int main()
{
testFunction();
return 0;
}
test.h
#ifndef TEST_H
#define TEST_H
#include <stdio.h>
#include <stdlib.h>
void testFunction();
#endif // TEST_H_INCLUDED
test.c的
#include "test.h"
void testFunction(){
#ifdef DEBUG
printf("I'm inside the testFunction\n");
#endif
}
问题:为什么程序不打印在的东西#ifdef DEBUG block?如果我在test.h或test.c中写入#define DEBUG一切都很好。那么问题是什么#define DEBUG在main.c中?谢谢。
downvote的原因是什么? – 2013-05-08 16:56:24