简体   繁体   English

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

[英]How to use this macro in my cpp program?

I have following macro with me. 我有以下宏。 I am getting error while using this macro. 使用此宏时出现错误。 If you observe it has no end bracket for schema::schema() . 如果您观察到它没有schema::schema()结尾括号。 This is my macro header file. 这是我的宏头文件。

#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(){ 

You can use it like so: 您可以这样使用它:

LoadSchemaDico(name)
//constructor code
}

Which will expand to: 它将扩展为:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM