expected ‘;’ at end of member declaration

963 views
Skip to first unread message

Nerijus Baliunas

unread,
Oct 16, 2016, 4:34:08 PM10/16/16
to wx-...@googlegroups.com
Hello,

While compiling wxMEdit I got:

In file included from /a/M/wxWindows.31/wxWidgets/include/wx/object.h:57:0,
from /a/M/wxWindows.31/wxWidgets/include/wx/event.h:16,
from /a/M/wxWindows.31/wxWidgets/include/wx/app.h:19,
from src/mad_utils.cpp:20:
/a/M/wxWindows.31/wxWidgets/include/wx/rtti.h:144:45: error: expected ‘;’ at end of member declaration
virtual wxClassInfo *GetClassInfo() const \
^

The error got away when I added semicolon at the end of the line:
virtual wxClassInfo *GetClassInfo() const; \

Regards,
Nerijus

Vadim Zeitlin

unread,
Oct 16, 2016, 5:28:35 PM10/16/16
to wx-...@googlegroups.com
On Sun, 16 Oct 2016 23:33:30 +0300 Nerijus Baliunas wrote:

NB> While compiling wxMEdit I got:

Sorry, what's this? Most importantly, do I understand correctly that line
20 of mad_utils.cpp contains wxDECLARE_ABSTRACT_CLASS() macro? And, if so,
is it followed by a semicolon (as it should be)?

NB> In file included from /a/M/wxWindows.31/wxWidgets/include/wx/object.h:57:0,
NB> from /a/M/wxWindows.31/wxWidgets/include/wx/event.h:16,
NB> from /a/M/wxWindows.31/wxWidgets/include/wx/app.h:19,
NB> from src/mad_utils.cpp:20:
NB> /a/M/wxWindows.31/wxWidgets/include/wx/rtti.h:144:45: error: expected ‘;’ at end of member declaration
NB> virtual wxClassInfo *GetClassInfo() const \
NB> ^
NB>
NB> The error got away when I added semicolon at the end of the line:
NB> virtual wxClassInfo *GetClassInfo() const; \

Do you use clang or gcc? I think fixing this is slightly more involved
than just adding a semicolon because with gcc this would result in two
semicolons in a row (with the one following the macro) and this will
probably result in warnings.

Regards,
VZ

Nerijus Baliunas

unread,
Oct 16, 2016, 6:26:07 PM10/16/16
to wx-...@googlegroups.com
On Sun, 16 Oct 2016 23:28:28 +0200 Vadim Zeitlin <va...@wxwidgets.org> wrote:

> On Sun, 16 Oct 2016 23:33:30 +0300 Nerijus Baliunas wrote:
>
> NB> While compiling wxMEdit I got:
>
> Sorry, what's this? Most importantly, do I understand correctly that line
> 20 of mad_utils.cpp contains wxDECLARE_ABSTRACT_CLASS() macro?

No, it contains #include <wx/gdicmn.h> - https://github.com/hltj/wxMEdit/blob/master/src/mad_utils.cpp

> NB> In file included from /a/M/wxWindows.31/wxWidgets/include/wx/object.h:57:0,
> NB> from /a/M/wxWindows.31/wxWidgets/include/wx/event.h:16,
> NB> from /a/M/wxWindows.31/wxWidgets/include/wx/app.h:19,
> NB> from src/mad_utils.cpp:20:
> NB> /a/M/wxWindows.31/wxWidgets/include/wx/rtti.h:144:45: error: expected ‘;’ at end of member declaration
> NB> virtual wxClassInfo *GetClassInfo() const \
> NB> ^
> NB>
> NB> The error got away when I added semicolon at the end of the line:
> NB> virtual wxClassInfo *GetClassInfo() const; \
>
> Do you use clang or gcc? I think fixing this is slightly more involved
> than just adding a semicolon because with gcc this would result in two
> semicolons in a row (with the one following the macro) and this will
> probably result in warnings.

gcc 6.2.1.

Regards,
Nerijus

Vadim Zeitlin

unread,
Oct 16, 2016, 6:43:58 PM10/16/16
to wx-...@googlegroups.com
On Mon, 17 Oct 2016 01:25:57 +0300 Nerijus Baliunas wrote:

NB> On Sun, 16 Oct 2016 23:28:28 +0200 Vadim Zeitlin <va...@wxwidgets.org> wrote:
NB>
NB> > On Sun, 16 Oct 2016 23:33:30 +0300 Nerijus Baliunas wrote:
NB> >
NB> > NB> While compiling wxMEdit I got:
NB> >
NB> > Sorry, what's this? Most importantly, do I understand correctly that line
NB> > 20 of mad_utils.cpp contains wxDECLARE_ABSTRACT_CLASS() macro?
NB>
NB> No, it contains #include <wx/gdicmn.h> - https://github.com/hltj/wxMEdit/blob/master/src/mad_utils.cpp
...
NB> gcc 6.2.1.

This is pretty weird, I don't have any problems with gcc 6.2.0:

% echo '#include <wx/gdicmn.h>'| g++-6 `wx-config --cxxflags` -x c++ -fsyntax-only -Wall -

succeeds. Can you please check if this works for you?

Thanks,
VZ

Nerijus Baliunas

unread,
Oct 17, 2016, 3:58:03 AM10/17/16
to wx-...@googlegroups.com
On Mon, 17 Oct 2016 00:43:51 +0200 Vadim Zeitlin <va...@wxwidgets.org> wrote:

> NB> gcc 6.2.1.
>
> This is pretty weird, I don't have any problems with gcc 6.2.0:
>
> % echo '#include <wx/gdicmn.h>'| g++-6 `wx-config --cxxflags` -x c++ -fsyntax-only -Wall -
>
> succeeds. Can you please check if this works for you?

Yes, it works.

Regards,
Nerijus

Vadim Zeitlin

unread,
Oct 19, 2016, 7:53:29 AM10/19/16
to wx-...@googlegroups.com
On Mon, 17 Oct 2016 10:57:26 +0300 Nerijus Baliunas wrote:

NB> On Mon, 17 Oct 2016 00:43:51 +0200 Vadim Zeitlin <va...@wxwidgets.org> wrote:
NB>
NB> > NB> gcc 6.2.1.
NB> >
NB> > This is pretty weird, I don't have any problems with gcc 6.2.0:
NB> >
NB> > % echo '#include <wx/gdicmn.h>'| g++-6 `wx-config --cxxflags` -x c++ -fsyntax-only -Wall -
NB> >
NB> > succeeds. Can you please check if this works for you?
NB>
NB> Yes, it works.

Sorry, I really don't know what's the difference with the real code then
and I just don't have time to start building some third party project here
right now. If you could please try to debug it a bit more, e.g. by looking
at the preprocessed output (add "-E" to the compiler command line), it
would be great.

TIA,
VZ

Nerijus Baliunas

unread,
Oct 19, 2016, 10:26:07 AM10/19/16
to wx-...@googlegroups.com
On Wed, 19 Oct 2016 13:53:24 +0200 Vadim Zeitlin <va...@wxwidgets.org> wrote:

> Sorry, I really don't know what's the difference with the real code then
> and I just don't have time to start building some third party project here
> right now. If you could please try to debug it a bit more, e.g. by looking
> at the preprocessed output (add "-E" to the compiler command line), it
> would be great.

After adding -E error is gone. Without -E:

g++ -DHAVE_CONFIG_H -I. -g -O2 -std=c++11 -pthread -I/usr/include/gtk-2.0 -I/usr/lib64/gtk-2.0/include -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libdrm -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/include -I/usr/include -I/a/M/wxWindows.31/build.gtk2/lib/wx/include/gtk2-unicode-3.1 -I/a/M/wxWindows.31/wxWidgets/include -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -DDATA_DIR=\"/usr/share\" -g -O2 -std=c++11 -pthread -I/usr/include/gtk-2.0 -I/usr/lib64/gtk-2.0/include -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libdrm -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libpng16 -MT src/wxmedit-mad_utils.o -MD -MP -MF src/.deps/wxmedit-mad_utils.Tpo -c -o src/wxmedit-mad_utils.o `test -f 'src/mad_utils.cpp' || echo './'`src/mad_utils.cpp
In file included from /a/M/wxWindows.31/wxWidgets/include/wx/event.h:16:0,
from /a/M/wxWindows.31/wxWidgets/include/wx/app.h:19,
from src/mad_utils.cpp:19:
/a/M/wxWindows.31/wxWidgets/include/wx/object.h:344:38: warning: unknown option after ‘#pragma GCC diagnostic’ kind [-Wpragmas]
wxDECLARE_ABSTRACT_CLASS(wxObject);
^

With -E:

g++ -DHAVE_CONFIG_H -I. -g -O2 -std=c++11 -pthread -I/usr/include/gtk-2.0 -I/usr/lib64/gtk-2.0/include -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libdrm -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/include -I/usr/include -I/a/M/wxWindows.31/build.gtk2/lib/wx/include/gtk2-unicode-3.1 -I/a/M/wxWindows.31/wxWidgets/include -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -DDATA_DIR=\"/usr/share\" -E -g -O2 -std=c++11 -pthread -I/usr/include/gtk-2.0 -I/usr/lib64/gtk-2.0/include -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libdrm -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libpng16 -MT src/wxmedit-mad_utils.o -MD -MP -MF src/.deps/wxmedit-mad_utils.Tpo -c -o src/wxmedit-mad_utils.o `test -f 'src/mad_utils.cpp' || echo './'`src/mad_utils.cpp
mv -f src/.deps/wxmedit-mad_utils.Tpo src/.deps/wxmedit-mad_utils.Po

Regards,
Nerijus

Vadim Zeitlin

unread,
Oct 19, 2016, 10:32:30 AM10/19/16
to wx-...@googlegroups.com
On Wed, 19 Oct 2016 17:25:31 +0300 Nerijus Baliunas wrote:

NB> On Wed, 19 Oct 2016 13:53:24 +0200 Vadim Zeitlin <va...@wxwidgets.org> wrote:
NB>
NB> > Sorry, I really don't know what's the difference with the real code then
NB> > and I just don't have time to start building some third party project here
NB> > right now. If you could please try to debug it a bit more, e.g. by looking
NB> > at the preprocessed output (add "-E" to the compiler command line), it
NB> > would be great.
NB>
NB> After adding -E error is gone.

Yes, this is normal as it doesn't compile the code. "-E" used to have a
look at the code after preprocessing, please try searching for the class
name in the (huge) generated output file and locate the lines corresponding
to the macro expansion.

Regards,
VZ

Nerijus Baliunas

unread,
Oct 19, 2016, 12:26:07 PM10/19/16
to wx-...@googlegroups.com
On Wed, 19 Oct 2016 16:32:29 +0200 Vadim Zeitlin <va...@wxwidgets.org> wrote:

> Yes, this is normal as it doesn't compile the code. "-E" used to have a
> look at the code after preprocessing, please try searching for the class
> name in the (huge) generated output file and locate the lines corresponding
> to the macro expansion.

It has such lines as:

class __attribute__ ((visibility("default"))) wxObject
{
public: static wxClassInfo ms_classInfo;
# 344 "/a/M/wxWindows.31/wxWidgets/include/wx/object.h"
#pragma GCC diagnostic push
# 344 "/a/M/wxWindows.31/wxWidgets/include/wx/object.h"

# 344 "/a/M/wxWindows.31/wxWidgets/include/wx/object.h"
#pragma GCC diagnostic ignored "-Winconsistent-missing-override"
# 344 "/a/M/wxWindows.31/wxWidgets/include/wx/object.h"
virtual wxClassInfo *GetClassInfo() const
# 344 "/a/M/wxWindows.31/wxWidgets/include/wx/object.h"
#pragma GCC diagnostic pop
# 344 "/a/M/wxWindows.31/wxWidgets/include/wx/object.h"
;

Shouldn't the last ";" be before #pragma GCC diagnostic pop?

Regards,
Nerijus

ARATA Mizuki

unread,
Oct 19, 2016, 2:20:00 PM10/19/16
to wx-...@googlegroups.com

> H28/10/20 1:25、Nerijus Baliunas <ner...@users.sourceforge.net>のメール:
In fact, there should be no #pragma's at all here. These pragmas are intended for clang, not GCC.

A change like this should work:

diff --git a/include/wx/defs.h b/include/wx/defs.h
index 1a35a67..423134b 100644
--- a/include/wx/defs.h
+++ b/include/wx/defs.h
@@ -641,7 +641,7 @@ typedef short int WXTYPE;
virtual wxClassInfo *GetClassInfo() const
wxCLANG_WARNING_RESTORE(inconsistent-missing-override)
*/
-#if defined(__has_warning)
+#if defined(__clang__) && defined(__has_warning)
# define wxCLANG_HAS_WARNING(x) __has_warning(x) /* allow macro expansion for the warning name */
# define wxCLANG_IF_VALID_WARNING(x,y) \
wxCONCAT(wxCLANG_IF_VALID_WARNING_,wxCLANG_HAS_WARNING(wxSTRINGIZE(wxCONCAT(-W,x))))(y)

Apparently, the definition of the macro wxCLANG_WARNING_SUPPRESS doesn't work well if __has_warning is defined by user code (in this case, <unicode/platform.h>).


ARATA Mizuki

Nerijus Baliunas

unread,
Oct 19, 2016, 4:14:04 PM10/19/16
to wx-...@googlegroups.com
On Thu, 20 Oct 2016 03:19:54 +0900 ARATA Mizuki <minor...@gmail.com> wrote:

> In fact, there should be no #pragma's at all here. These pragmas are intended for clang, not GCC.

Yes, clang compiles OK.

> A change like this should work:

> -#if defined(__has_warning)
> +#if defined(__clang__) && defined(__has_warning)

Thank you, with this change both gcc and clang compile successfully.

Regards,
Nerijus

Vadim Zeitlin

unread,
Oct 21, 2016, 5:06:46 PM10/21/16
to wx-...@googlegroups.com
On Thu, 20 Oct 2016 03:19:54 +0900 ARATA Mizuki wrote:

AM> > H28/10/20 1:25、Nerijus Baliunas <ner...@users.sourceforge.net>のメール:
AM> >
AM> > On Wed, 19 Oct 2016 16:32:29 +0200 Vadim Zeitlin <va...@wxwidgets.org> wrote:
AM> >
AM> >> Yes, this is normal as it doesn't compile the code. "-E" used to have a
AM> >> look at the code after preprocessing, please try searching for the class
AM> >> name in the (huge) generated output file and locate the lines corresponding
AM> >> to the macro expansion.
AM> >
AM> > It has such lines as:
AM> >
AM> > class __attribute__ ((visibility("default"))) wxObject
AM> > {
AM> > public: static wxClassInfo ms_classInfo;
AM> > # 344 "/a/M/wxWindows.31/wxWidgets/include/wx/object.h"
AM> > #pragma GCC diagnostic push
AM> > # 344 "/a/M/wxWindows.31/wxWidgets/include/wx/object.h"
AM> >
AM> > # 344 "/a/M/wxWindows.31/wxWidgets/include/wx/object.h"
AM> > #pragma GCC diagnostic ignored "-Winconsistent-missing-override"
AM> > # 344 "/a/M/wxWindows.31/wxWidgets/include/wx/object.h"
AM> > virtual wxClassInfo *GetClassInfo() const
AM> > # 344 "/a/M/wxWindows.31/wxWidgets/include/wx/object.h"
AM> > #pragma GCC diagnostic pop
AM> > # 344 "/a/M/wxWindows.31/wxWidgets/include/wx/object.h"
AM> > ;
AM> >
AM> > Shouldn't the last ";" be before #pragma GCC diagnostic pop?
AM>
AM> In fact, there should be no #pragma's at all here. These pragmas are
AM> intended for clang, not GCC.

I still wonder if it's a good idea to put a pragma in the middle of a
statement like this. Apparently this doesn't create any problems for clang
right now, but it's definitely unusual. Do you think this could ever become
a problem in the future?

AM> A change like this should work:
AM>
AM> diff --git a/include/wx/defs.h b/include/wx/defs.h
AM> index 1a35a67..423134b 100644
AM> --- a/include/wx/defs.h
AM> +++ b/include/wx/defs.h
AM> @@ -641,7 +641,7 @@ typedef short int WXTYPE;
AM> virtual wxClassInfo *GetClassInfo() const
AM> wxCLANG_WARNING_RESTORE(inconsistent-missing-override)
AM> */
AM> -#if defined(__has_warning)
AM> +#if defined(__clang__) && defined(__has_warning)
AM> # define wxCLANG_HAS_WARNING(x) __has_warning(x) /* allow macro expansion for the warning name */
AM> # define wxCLANG_IF_VALID_WARNING(x,y) \
AM> wxCONCAT(wxCLANG_IF_VALID_WARNING_,wxCLANG_HAS_WARNING(wxSTRINGIZE(wxCONCAT(-W,x))))(y)

We could do this, but I don't really like it because if another compiler
starts providing __has_warning (e.g. icc perhaps or whatever else) we
probably want to use the same pragmas for it, there doesn't seem any reason
to limit this to the real clang only.

AM> Apparently, the definition of the macro wxCLANG_WARNING_SUPPRESS
AM> doesn't work well if __has_warning is defined by user code (in this
AM> case, <unicode/platform.h>).

Wait, do you mean that this project defines __has_warning in its own code?
If so, I think they deserve what they get. This is a reserved identifier
and, unlike the ones we use "_WX_whatever", defining this one clearly is a
problem. If I understood you correctly, they should really just stop doing
this.

Regards,
VZ

Nerijus Baliunas

unread,
Oct 24, 2016, 5:20:04 AM10/24/16
to wx-...@googlegroups.com
On Fri, 21 Oct 2016 23:06:45 +0200 Vadim Zeitlin <va...@wxwidgets.org> wrote:

> Wait, do you mean that this project defines __has_warning in its own code?

Does not seem so, I did not find __has_warning in its build (and source) dir.

Regards,
Nerijus

Matthew Heinsen Egan

unread,
Mar 17, 2017, 8:52:36 PM3/17/17
to wx-dev
Hello all,

Just chiming in because I recently experienced this problem with a different project. It seems to me that it's caused by including ICU and wxWidgets - ICU defines __has_warning(x) 0, if __has_warning was not already defined. Is there a recommended method to dealing with this? (It would be nice for me if ICU and wxWidgets played nicely together without having to do anything special :).

Kind regards,
Matthew

Vadim Zeitlin

unread,
Mar 19, 2017, 7:28:46 PM3/19/17
to wx-...@googlegroups.com
On Fri, 17 Mar 2017 17:52:35 -0700 (PDT) Matthew Heinsen Egan wrote:

MHE> On Monday, 24 October 2016 18:20:04 UTC+9, nerijus wrote:
MHE> >
MHE> > On Fri, 21 Oct 2016 23:06:45 +0200 Vadim Zeitlin <va...@wxwidgets.org
MHE> > <javascript:>> wrote:
MHE> >
MHE> > > Wait, do you mean that this project defines __has_warning in its own
MHE> > code?
MHE> >
MHE> > Does not seem so, I did not find __has_warning in its build (and source)
MHE> > dir.
MHE> >
MHE> > Regards,
MHE> > Nerijus
MHE> >
MHE>
MHE> Hello all,
MHE>
MHE> Just chiming in because I recently experienced this problem with a
MHE> different project. It seems to me that it's caused by including ICU and
MHE> wxWidgets - ICU defines __has_warning(x) 0, if __has_warning was not
MHE> already defined. Is there a recommended method to dealing with this? (It
MHE> would be nice for me if ICU and wxWidgets played nicely together without
MHE> having to do anything special :).

You can either include wx headers first or #undef __has_warning after
including ICU and before including wx or, probably the best and simplest
solution, get or apply the change just done in this commit:

https://github.com/wxWidgets/wxWidgets/commit/3b298cc8b2a22fca0aed1d457512738bf11e3bbb

Regards,
VZ

Matthew Heinsen Egan

unread,
Mar 22, 2017, 12:54:48 AM3/22/17
to wx-...@googlegroups.com
Lovely, thanks :)

Kind regards,
Matthew
Reply all
Reply to author
Forward
0 new messages