Currently you have to specify the name of the module whenever you use a module MACRO, like __bgdexport or LOCINT32. However, using correct MACRO expansion, this can be made easier.
For example for __bgdexport and LOCINT32:
#define DLLNAME mod_map
#undef __bgdexport
#define __bgdexport(a) x__bgdexport(DLLNAME,a)
#define x__bgdexport(d,a) y__bgdexport(d,a)
#define y__bgdexport(m,a) m##_##a
#undef LOCINT32
#define LOCINT32(p,v) xLOCINT32(DLLNAME,p,v)
#define xLOCINT32(d,p,v) yLOCINT32(d,p,v)
#define yLOCINT32(m,a,b) (*(int32_t *)LOCADDR(m,a,b))
Another thing: -DVERSION=\"0.93\" is used (and other strings), however, I believe this is not portable to every compiler. A solution is -DVERSION=0.93 and use:
#define STRINGIFY(s) xSTRINGIFY(s)
#define xSTRINGIFY(s) #s
and then use STRINGIFY(VERSION) to get "0.93".
I didn't have problems with this until recently when I used a GCC for GP2X.
little weired...
indirect use of ## not works in all gnu compilers... of fact, I can't didn't works it... I was say you this time ago... I was tried use it when I made the first bgdexport... and it don't works...
but, # can be used indirectly...
the ##_## expand of this give 'd_a' and not 'mod_map_a'... ## in defines expand the literal arguments...
take a look of this http://en.wikipedia.org/wiki/C_preprocessor
Yeah I remember our chat when you first made it, but I don't remember whether you used another indirection or not. This works for me (mingw gcc 3.4.5) anyway. If it doesn't work for you, then it cannot be used. Damn! :(
oh, no... I now remember... indirection works... don't works this...
#define DLLNAME mod_map
#undef __bgdexport
#define __bgdexport(a) ___bgdexport(DLLNAME,a)
#define ___bgdexport(m,a) m##_##a
2 (defines) and DLLNAME was not expanded, it's used as literal....
but, I don't tried with 3 defines...
#define DLLNAME mod_map
#undef __bgdexport
#define __bgdexport(a) ___bgdexport(DLLNAME,a)
#define ___bgdexport(d,a) ____bgdexport(d,a)
#define ____bgdexport(m,a) m##_##a
maybe this can works... I'll try it... thanks...
Yes, exactly. Because in ___bgdexport, the MACRO DLLNAME is expanded to mod_map and THEN passed to ____bgdexport, which concatenates it. As far as I know this should work. :)
I think so...