Boost logo

Boost :

From: Ross Smith (r-smith_at_[hidden])
Date: 2002-02-24 02:44:17


Alan Bellingham wrote:
>
> At the moment, I'm looking at producing a set of headers - an undef and
> redef pair to shadow each Win32 header - and including those actually
> required.
>
> // user's source file
> #include <winbase.h>
> #include ... // all other Win32 headers used
> #include "undefs.h"
> #include "redefs.h"
> #include ... // all other headers required
>
> // undefs.h
> #if defined(INC_WINBASE_H) // or whatever the guard actually is ...
> # include "undef_winbase.h"
> #endif
>
> // redefs.h
> #if defined(INC_WINBASE_H) // or whatever the guard actually is ...
> # include "redef_winbase.h"
> #endif
>
> // undef_winbase.h
> #if defined(GetFileAttributes)
> # undef GetFileAttributes
> #endif // defined(GetFileAttributes)
>
> // redef_winbase.h
> inline DWORD GetFileAttributes(char const* FileName)
> {
> return GetFileAttributesA(FileName) ;
> }
> inline DWORD GetFileAttributes(wchar_t const* FileName)
> {
> return GetFileAttributesW(FileName) ;
> }

It occurs to me that, if you're going to write all that code for every
API function (pair) that you use anyway, it may be simpler just to leave
the Windows headers out altogether and simply write your own headers
with just the extern declarations for FooA() and FooW() and your
overloaded Foo(), losing the macros completely. (Also that it probably
wouldn't be terribly difficult to automate the header conversion
process.)

-- 
Ross Smith ...................................... Auckland, New Zealand
r-smith_at_[hidden] ......................... http://storm.net.nz/~ross/
  "We need a new cosmology. New gods. New sacraments. Another drink."
                                                       -- Patti Smith

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk