简体   繁体   中英

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() . 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
} 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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