The only alternative to scattering compiler-dependent #ifdefs through
the code that I am aware of is to conditionally #define some macros
at the beginning of a header file that gets included in everything.
I've seen things like
// At the top of some global .h file
#ifdef (__cplusplus)
#define EXTERN_C_START extern "C" {
#define EXTERN_C_END }
#else
#define EXTERN_C_START
#define EXTERN_C_END
#end
and then use EXTERN_C_START and EXTERN_C_END instead of conditional
compile statements in header files using C conventions. Both Apple
and MS use this technique extensively for pseudo-qualifiers and
pseudo-types. On Windows __cdecl, __stdecl, ad inf., on Mac
<CarbonCore/ConditionalMacros.h> does tons conditional #defines.
Dunno which alternative is better practice. Also, I don't think you
can get this to work with #pragmas. I think something like the
following won't work:
---------------------------------
#ifdef (_MSC_VER)
#define PRAGMA_NOWARN(X) #pragma warning(disable: X)
#else
#define PRAGMA_NOWARN(X)
#endif
PRAGMA_NOWARN(4133) // This ain't gonna do what I want, is it?
---------------------------------
Any preprocessor gurus out there who can prove me wrong? Some funky
post-K&RII macro substitution?
-- P.
On 4-May-2007, at 14:19, Roger Dannenberg wrote:
I didn't mean to imply your code was wrong, and in fact I don't
think I thought of using ifdefs to isolate pragmas when I was
trying to do something in the past. I was only wondering if it's
the best way -- I figure many have dealt with this, but I've never
seen any discussion of best practices. -Roger
-------------- http://www.bek.no/~pcastine/Litter/ -------------
Peter Castine +--> Litter Power & Litter Bundle for Jitter
Universal Binaries on the way
iCE: Sequencing, Recording &
Interface Building for |home | chez nous|
Max/MSP Extremely cool |bei uns | i nostri|
http://www.dspaudio.com/ http://www.castine.de
_______________________________________________
media_api mailing list
[email protected]
http://www.create.ucsb.edu/mailman/listinfo/media_api