|
From: Mojca M. <moj...@gm...> - 2013-06-22 21:00:13
|
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"));
^
See also
http://stackoverflow.com/questions/12023653/how-do-i-disable-add-explicit-braces-to-avoid-dangling-else-in-new-xcode
and the comment: "imo it's a bug, but apple developer support has his
own definition of dangling-else: This is only a style warning. This
code is inherently hard to read, which is why the warning exists. If
you do not like the warning you can silence it by passing
-Wno-dangling-else to the compiler. – peko May 24 at 13:49"
It needs a trivial patch and I can send one, but only if you agree to
patch the code (= add extra braces).
Mojca
|
|
From: Mojca M. <moj...@gm...> - 2013-06-22 21:44:44
Attachments:
dangling_else.diff
|
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.)
Thank you,
Mojca
|
|
From: Ethan M. <merritt@u.washington.edu> - 2013-06-24 04:28:09
|
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.
Ethan
>
> Thank you,
> Mojca
|
|
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
|