$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2006-04-08 15:50:10
Roland Schwarz wrote:
> I am wondering if it would be possible to write a computed include macro 
> that is sufficiently compiler independent?
> 
> E.e. given a macro
> 
> #define BOOST_PLATFORM_INCLUDE(hdr) ... definition missing ...
> 
> which should be usable as:
> 
> #include BOOST_PLATFORM(foo.h)
> 
> The effect being win32/foo.h included on one linux/foo.h included on 
> another platform.
> 
> I have yet figured out a way that can achieve something close, but gcc 
> does not allow to use a parameterized macro.
Where is the problem?
    #if defined(linux) || defined(__linux) || defined(__linux__)
    #  define PLATFORM_HEADER_DIRECTORY linux
    #elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
    #  define PLATFORM_HEADER_DIRECTORY windows
    // [...]
    #endif
    #define PLATFORM_HEADER(header) <PLATFORM_HEADER_DIRECTORY/header>
    #include PLATFORM_HEADER(foo.h)
Should work. I've no idea how portable it is, though. 
If you need quotes instead use BOOST_PP_STRINGIZE:
    #define PLATFORM_HEADER(header) \
        BOOST_PP_STRINGIZE(PLATFORM_HEADER_DIRECTORY/header)
Regards,
Tobias