如何在我的cpp程序中使用这个宏

How to use this macro in my cpp program?

本文关键字:程序 我的 cpp      更新时间:2023-10-16

我有以下宏与我。我得到错误,而使用这个宏。如果你观察到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(){ 

你可以这样使用:

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
}