Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/154.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何在我的cpp程序中使用此宏?_C++_Macros - Fatal编程技术网

C++ 如何在我的cpp程序中使用此宏?

C++ 如何在我的cpp程序中使用此宏?,c++,macros,C++,Macros,我随身带着下面的宏。使用此宏时出现错误。如果您观察到,它的schema::schema()没有结束括号。这是我的宏头文件 #ifdef _WINDOWS_SOURCE #define ExportedByVX0TOOLS __declspec(dllexport) #else #define ExportedByVX0TOOLS #endif #include <stdio.h> #include <string.h> // #if defined(_WINDOW

我随身带着下面的宏。使用此宏时出现错误。如果您观察到,它的
schema::schema()
没有结束括号。这是我的宏头文件

#ifdef _WINDOWS_SOURCE
#define ExportedByVX0TOOLS  __declspec(dllexport)  
#else
#define ExportedByVX0TOOLS
#endif

#include <stdio.h>
#include <string.h>
//
#if defined(_WINDOWS_SOURCE)
#include <errno.h>
#include <io.h>
#endif
#if defined(_IRIX_SOURCE) || defined(_SUNOS_SOURCE) || defined(_HPUX_SOURCE) || defined(_AIX)
#include <stdlib.h>
#include <sys/stat.h>
#include <unistd.h>
#endif

#define LoadSchemaDico(schema)\
        class ExportedByVX0TOOLS schema { public: schema();};\
        extern "C" ExportedByVX0TOOLS int fctCreate##schema();\
        int  fctCreate##schema(){ int ret=1 ; return ret; }\
        schema::schema(){ 
\ifdef\u WINDOWS\u源代码
#定义由Vx0Tools导出的declspec(dllexport)
#否则
#定义导出的Vx0工具
#恩迪夫
#包括
#包括
//
#如果已定义(\u WINDOWS\u源)
#包括
#包括
#恩迪夫
#如果已定义(_IRIX_SOURCE)|已定义(_SUNOS_SOURCE)|已定义(_HPUX_SOURCE)|已定义(_AIX)
#包括
#包括
#包括
#恩迪夫
#定义LoadSchemaDico(模式)\
类ExportedByVX0TOOLS架构{public:schema();}\
Vx0Tools int fctCreate##schema()导出的外部“C”\
int fctCreate##schema(){int ret=1;return ret;}\
schema::schema(){

您可以这样使用它:

LoadSchemaDico(name)
//constructor code
}
这将扩展到:

class ExportedByVX0TOOLS name
{ 
   public: 
       name();
};
extern "C" ExportedByVX0TOOLS int fctCreatename();
int  fctCreatename()
{ 
   int ret=1 ; 
   return ret; 
}
name::name()
{
//constructor code
} 

我现在想,你是如何使用宏的?我有点担心,如果我想为这个扩展模式创建C++类的对象,我该怎么做??谢谢。但是如果我想在运行时检索生成的类的名字,我怎么能这么做。通常我们知道这个名字,因为我们给了它。但是我想检索它像动态加载的运行时间。@ USE1061293-这样,你不能。C++不支持反射。可能帮助你的是抽象。t工厂的设计模式,可能想研究一下。