Even the simplest class doesn't compile, "has not been declared

后端 未结 2 415
天涯浪人
天涯浪人 2021-01-22 19:49

OK, this is really annoying. I have the (almost) simplest class possible. Two files: a.cpp and a.h a.h:

#ifdef A_H
#define A_H
class a{
  public:
    a();
};
#en         


        
2条回答
  •  悲&欢浪女
    2021-01-22 20:13

    Replace #ifdef with #ifndef, then try again.

    There are some IDEs I find very helpful, that parse the code while you type and show in 'gray' font the code that is not going to be compiled, as of the current macro definitions. Moreover, running

    gcc -E

    followed by the gcc arguments you already know, will show you what's the code going to be compiled after preprocessing (macros are resolved by the preprocessor, the initial step of the compilation-building toolchain).

提交回复
热议问题