Listing 10: Type-tunneling via c_str_ptr access shim
/* ///////////////////////////////////////////////////////////// * Extract from the Game Framework * * www: http://www.gameframework.com/ * * Copyright (C) 2001, 2002, Scott Patterson, Matthew Wilson. * (Licensed under the Synesis Software Standard Source License: * http://www.synesis.com.au/licenses/ssssl.html) * ////////////////////////////////////////////////////////// */ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ void GFAssert2A( gf_char_a_t const *file , int line , gf_char_a_t const *expression , gf_char_a_t const *message); void GFAssert2W( . . . ); #ifdef __cplusplus } /* extern "C" */ inline void _GFAssert2( gf_char_a_t const *file , int line , gf_char_a_t const *expression , gf_char_a_t const *message) { GFAssert2A(file, line, expression, message); } inline void _GFAssert2( gf_char_w_t const *file , int line , gf_char_w_t const *expression , gf_char_w_t const *message) { GFAssert2W(file, line, expression, message); } template <typename S1, typename S2> inline void GFAssert2 ( gf_char_a_t const *file , int line , S1 const &expression , S2 const &message) { _GFAssert2(file, line, c_str_ptr(expression), c_str_ptr(message)); } #endif /* __cplusplus */ #ifdef __cplusplus #define GFASSERTMSG(f, sz) \ ((void)((!(f)) ? GFAssert2(__FILE__, __LINE__, #f, sz) : (0))) #else . . . // C translation must employ character encoding discrimination #endif /* __cplusplus */