0

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(){ 
2
  • 1
    How are you using the macro as of now? Commented Nov 30, 2011 at 8:38
  • 1
    With some trepidation, I imagine! Commented Nov 30, 2011 at 8:39

1 Answer 1

1

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 } 
Sign up to request clarification or add additional context in comments.

4 Comments

If i want to create the object for this expanded schema to c++ class, how can i do that??
@user1061293 you can just do "name obj;" or "name* obj = new name;", replacing name with the name of your class.
Thanks..But if i want to retrieve the name of the generated class at runtime, how can i do that..Usually we knows the name, because we give it. But i want to retrieve it run time like dynamic loading..
@user1061293 In this way, you can't. C++ doesn't support reflection. What might help you is the abstract factory design patter, might want to look into that.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.