C++ C++;将宏视为一个类
在visual studio中,我将配置类型设置为.dll而不是.exe,因此有时我需要使用C++ C++;将宏视为一个类,c++,visual-studio,class,macros,C++,Visual Studio,Class,Macros,在visual studio中,我将配置类型设置为.dll而不是.exe,因此有时我需要使用\uu declspec(dllexport)或\uu declspec(dlliport)。所以我在名为“Core”的头文件中为它们创建了宏 我的命名空间“Bos5”中有一个类“Application”,它使用BS\u API #pragma once #include "Core.h" namespace Bos5 { class B5_API Application
\uu declspec(dllexport)
或\uu declspec(dlliport)
。所以我在名为“Core”的头文件中为它们创建了宏
我的命名空间“Bos5”中有一个类“Application”,它使用BS\u API
#pragma once
#include "Core.h"
namespace Bos5 {
class B5_API Application
{
public:
Application();
~Application();
void Run();
};
}
在这个项目中一切都很好,但当我出于某种原因将其引用到另一个项目时,VisualStudio认为B5_API是一个类,“应用程序”不是。因此,下面的代码不会编译说命名空间Bos5没有名为“Application”的结构或类
#包括
类沙盒:公共Bos5::应用程序
{
公众:
沙盒(){}
~Sandbox(){}
};
int main(){
}
我认为这张图片可以更好地解释我说的话好的,我已经修正了。结果问题完全不同了。我的预处理器没有保存一些定义,所以在第二个项目B5_API没有得到定义你需要
#包括“Core.h”
,这样才能#定义B5_API(dllimport)
你确定它没有编译,或者你只是看到红色的曲线?编辑器的实时检查通常不像实际的编译器那样正确。我在application.h中有这样的功能。如果我在同一个项目中做类似的事情,其中声明了应用程序类,那么一切都正常工作fine@aschepler实际上,由于其他一些原因,它没有编译,但我担心那些红色的曲线。
#pragma once
#include "Core.h"
namespace Bos5 {
class B5_API Application
{
public:
Application();
~Application();
void Run();
};
}
#include <FinalBos5.h>
class Sandbox : public Bos5::Application
{
public:
Sandbox(){}
~Sandbox(){}
};
int main() {
}