objective c - Defining const in precompiled header -- How to avoid duplication -


i want use cocoalumberjack , trying insert ddloglevel const in .pch file:

#if debug static const int ddloglevel = log_level_verbose; #else static const int ddloglevel = log_level_info; #endif 

however, since i'm using xmpp framework, , uses cocoalumberjack, i'm getting redefinition of 'ddloglevel' errors since classes contain exact same const definitions above.

i don't want define ddloglevel in every 1 of classes avoid this. how can around this?

you add guard around it. this:

#ifndef ddloglevel #if debug static const int ddloglevel = log_level_verbose; #else static const int ddloglevel = log_level_info; #endif //debug #endif //ddloglevel 

if cannot use ddloglevel guard: (cannot test right now)

#ifndef ddloglevel #if debug #define ddloglevel static const int ddloglevel = log_level_verbose; #else static const int ddloglevel = log_level_info; #endif //debug #endif //ddloglevel 

i hope works.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -