C++ Conditional compilation directives: multiple files

  c++, compilation, preprocessor, visual-studio

I have 2 files,main.cpp and head.h

#define DEBUG2019 1
#include 'head.h' 
int main{
A A1;
return 0;

class A{
#ifdef DEBUG2019
int p;
int q;

Look, I have defined DEBUG2019 in main.cpp. But in my visual studio 2019, the int p is still greyed out in head.h. Why is that? Why head.h does not know that DEBUG2019 has been defined? You may suggest me to define DEBUG2019 in the header file directly. But I have to define it in main.cpp.

Source: Windows Questions C++