   Including a class depending on a #define
  I'm coding a cross-platform engine and was wondering how to include a specific file transparently depending on a #define. An example is my graphics system class. I've got a version working in SDL and a version for the Nintendo DS. I have a #define _PC declared for the PC build, otherwise this is absent. The interface for the PC and DS version of the class is identical.Currently I have this:#ifdef _PC#include "sys_graphicsDS.h"#else#include "sys_graphicsSDL.h"#endif //_PCHowever I need to do this everytime I need to include the graphics system header. I'd like to be able to simply type this:#include "sys_graphics.h"I tried to put the above '#ifdef _PC' code within a sys_graphics.h, so that the decision to include the SDL or DS version of the file was made there, but this didn't seem to work.Does anyone have another solution? I'd like to avoid using an abstract base class for this even though it may seem like an ideal solution I'm not convinced. I don't plan to swap graphics system dynamically and I am happy to be responsible for keeping the interfaces identical myself without relying on an abstract base class to tell me off when I get things wrong. Then again if anyone offers a convincing arguement I could be convinced otherwise ;)   
Quote:Original post by nukomodI tried to put the above '#ifdef _PC' code within a sys_graphics.h, so that the decision to include the SDL or DS version of the file was made there, but this didn't seem to work.Define "didn't seem to work".   ;  That should have worked. Note that in the example you gave, if _PC is defined, it will include sys_graphicsDS.h, which might be your problem.What particular errors did you get when you tried it?   ;Quote:Original post by nukomodCurrently I have this:#ifdef _PC#include "sys_graphicsDS.h"#else#include "sys_graphicsSDL.h"#endif //_PCHowever I need to do this everytime I need to include the graphics system header. I'd like to be able to simply type this:#include "sys_graphics.h"I tried to put the above '#ifdef _PC' code within a sys_graphics.h, so that the decision to include the SDL or DS version of the file was made there, but this didn't seem to work.Since you define _PC on the PC build... you should also include the correct header :).... It should work if you put them correctly.#ifdef _PC#include "sys_graphicsSDL.h"#else#include "sys_graphicsDS.h"#endif //_PCEDIT:Took too much time to write it... :)   ;  You're all right, it does work.. I just hadn't used the right paths on the includes... now I feel dumb lol, but glad it works :)   