Problem: handling a function dependent on release mode.

Damian damianday at hotmail.co.uk
Fri Jul 20 14:54:50 PDT 2012


On Friday, 20 July 2012 at 21:47:55 UTC, Namespace wrote:
> On Friday, 20 July 2012 at 21:36:59 UTC, Damian wrote:
>> Trying to convert the below code to D, for the life of me I
>> cannot do it :( I'm guess I need to use a template for this
>> but I just cannot get my head around it. Any help please?
>>
>> #ifdef SFML_DEBUG
>>
>>     // If in debug mode, perform a test on every call
>>     #define alCheck(Func) ((Func), priv::alCheckError(__FILE__,
>> __LINE__))
>>
>> #else
>>
>>     // Else, we don't add any overhead
>>     #define alCheck(Func) (Func)
>>
>> #endif
>>
>>
>> void alCheckError(const std::string& file, unsigned int line);
>
> Maybe something like that?
>
> void alCheck(lazy void Func, string filename = __FILE__, uint
> line = __LINE__) {
> 	Func();
> 	
> 	debug {
> 		alCheckError(filename, line);
> 	}
> }

That works perfect, you sir are a genius!



More information about the Digitalmars-d-learn mailing list