c++ - Using the #define macro to standardize class declaration -
i'm building c++ dll 1 of projects. trying standardize way class defined. instead of each time writing:
class __declspec(dllexport) classname i'm building #define macro ease process:
#define class( cname ) class __declspec(dllexport) cname but, when i'm using it, gives me following error:
error: expected ';' i know can use #define macro define entire class creation, can used define "class header" ?
thanks,
keep in mind i'm trying because going deal hundreds of classes, these kinds of "automation" helpful :)
edit:
example:
#define class( nclass ) class __declspec(dllexport) nclass class( aptest ) { // here error of missing ';' public: aptest(); };
don't this.
c++ has been standardized!
if ever expect other people read code write in conventional c++, not homecooked dialect looks different. used proper c++ syntax, make easier read other people's c++ code.
one thing make sense simplify __declspec part, can this:
#ifdef _win32 #define dllexport __declspec(dllexport) #else #define dllexport #endif class dllexport aptest { // ... }; you're not making life simpler writing class( aptest ) , make harder others understand. no.
Comments
Post a Comment