|
From: Mojca M. <moj...@gm...> - 2013-06-24 15:05:46
|
On Mon, Jun 24, 2013 at 6:25 AM, Ethan Merritt wrote:
> On Saturday, June 22, 2013 11:44:36 PM Mojca Miklavec wrote:
>> On Sat, Jun 22, 2013 at 11:00 PM, Mojca Miklavec wrote:
>> > Hi,
>> >
>> > just to let you know: the compiler (I just updated to a newer version
>> > of Xcode) started complaining about "missing braces":
>> >
>> > wxterminal/wxt_gui.cpp:1500:4: warning: add explicit braces to avoid
>> > dangling else [-Wdangling-else]
>> >
>> > wxLogError(wxT("Cannot write raise"));
>> > ^
>>
>> I'm sorry, I've sent an incomplete error report earlier (because I
>> thought at first that the other errors were unrelated). The problem is
>> that wxLogError is a macro itself which expands into some if-else
>> clauses and one indeed ends up with "if ... if ... else", so maybe the
>> compiler is right after all. I'm attaching the patch. If you apply it,
>> please also patch the stable branch.
>>
>> wxterminal/wxt_gui.cpp:1500:4: warning: add explicit braces to avoid
>> dangling else [-Wdangling-else]
>> wxLogError(wxT("Cannot write raise"));
>> ^
>> /opt/local/include/wx-2.9/wx/log.h:1360:20: note: expanded from macro
>> 'wxLogError'
>> #define wxLogError wxDO_LOG_IF_ENABLED(Error)
>> ^
>> /opt/local/include/wx-2.9/wx/log.h:1353:5: note: expanded from macro
>> 'wxDO_LOG_IF_ENABLED'
>> else
>> \ ^
>> wxterminal/wxt_gui.cpp:1502:4: warning: add explicit braces to avoid
>> dangling else [-Wdangling-else]
>> wxLogError(wxT("Cannot write persist"));
>> ^
>> /opt/local/include/wx-2.9/wx/log.h:1360:20: note: expanded from macro
>> 'wxLogError'
>> #define wxLogError wxDO_LOG_IF_ENABLED(Error)
>> ^
>> /opt/local/include/wx-2.9/wx/log.h:1353:5: note: expanded from macro
>> 'wxDO_LOG_IF_ENABLED'
>> else
>> \ ^
>>
>> (Of course it wouldn't hurt if wxWidgets would put a pair of braces
>> into their source code where wxDO_LOG_IF_ENABLED is defined, but
>> that's another story.)
>
> On wxt2.8 as installed here, wxLogError() is a function provided by a
> library. It is not a macro. So the message you show makes no sense to me.
> The on-line docs also list it as a function, so far as I tell tell.
OK, I have 2.9.4, and according to this:
https://github.com/wxWidgets/wxWidgets/blob/master/include/wx/log.h
it seems that the code I have installed is "the latest one".
#define wxDO_LOG_IF_ENABLED(level) \
if ( !wxLog::IsLevelEnabled(wxLOG_##level, wxLOG_COMPONENT) ) \
{} \
else \
wxDO_LOG(level)
// wxLogFatalError() is special as it can't be disabled
#define wxLogFatalError wxDO_LOG(FatalError)
#define wxVLogFatalError(format, argptr) wxDO_LOGV(FatalError, format, argptr)
#define wxLogError wxDO_LOG_IF_ENABLED(Error)
Unless you consider this being a bug in wxt and someone submits a bug
report, this will probably end up in 3.0, so one would face the
problem sooner or later.
Mojca
|