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
Post a Comment