私は3つのファイルを持っています:
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ブロックに何かを出力しないのはなぜですか? #define DEBUGを test.h または test.cに記述すれば、すべて問題ありません。main.c で#define DEBUGを実行すると何が問題になるのでしょうか? ありがとう。