Precompile header question

20 views
Skip to first unread message

Frode Roxrud Gill

unread,
Jan 12, 2023, 5:45:19 PM1/12/23
to wx-dev
For reasons, I am currently building kicad@master against
wxWidgets@master, and it fails miserably. The biggest problem is
wxASSERT complaining about not knowing wxSTATEMENT_MACRO_BEGIN.

Should include/wx/debug.h include "wx/cpp.h"? Or what would be the
best way of handling this?

--
Frode Roxrud Gill

Vadim Zeitlin

unread,
Jan 12, 2023, 6:00:13 PM1/12/23
to wx-...@googlegroups.com
On Thu, 12 Jan 2023 23:45:06 +0100 Frode Roxrud Gill wrote:

FRG> For reasons, I am currently building kicad@master against
FRG> wxWidgets@master, and it fails miserably.

Could you please show the full compiler command line and the (first few)
errors?

FRG> The biggest problem is wxASSERT complaining about not knowing
FRG> wxSTATEMENT_MACRO_BEGIN.

This shouldn't be a problem, wxASSERT is a macro and it doesn't matter
what it contains until it's expanded, which doesn't happen in wx/debug.h.
But besides this, wx/cpp.h should have been already included anyhow, see
below.

FRG> Should include/wx/debug.h include "wx/cpp.h"? Or what would be the
FRG> best way of handling this?

wx/cpp.h should already be included from all code using wx. Granted, it's
done in a rather roundabout way, as it's include via wx/version.h which is
included from wx/defs.h, instead of being included by it directly, but it
still should be included.

IOW it seems impossible that wxSTATEMENT_MACRO_BEGIN is undefined if
wxASSERT is. I suspect that you have a mix of different wx headers on your
system that somehow result in the problem you're seeing. But it's really
difficult to say without any details whatsoever about what the actual
problem is.

Regards,
VZ

Frode Roxrud Gill

unread,
Jan 12, 2023, 6:45:32 PM1/12/23
to wx-...@googlegroups.com
On Fri, 13 Jan 2023 at 00:00, Vadim Zeitlin <va...@wxwidgets.org> wrote:
>
> On Thu, 12 Jan 2023 23:45:06 +0100 Frode Roxrud Gill wrote:
>
> FRG> For reasons, I am currently building kicad@master against
> FRG> wxWidgets@master, and it fails miserably.
>
> Could you please show the full compiler command line and the (first few)
> errors?

On Debian Testing, wxWidgets is compiled with `make -j 6` after
running `../../configure --with-gtk=3 --enable-threads
--enable-secretstore --enable-exceptions --enable-stl
--enable-std-containers --enable-debug --with-opengl --with-sdl
--disable-compat30`

kicad is simply built with `make -j 6`

This time it failed at wxCHECK_MSG, but I guess wxASSERT and
wxCHECK_MSG would be two very similiar cases.

kicad build output:

<snip>
-- Found wxWidgets:
-L/usr/local/lib;-pthread;;;-lwx_gtk3u_gl-3.3;-lwx_gtk3u_aui-3.3;-lwx_gtk3u_html-3.3;-lwx_gtk3u_core-3.3;-lwx_baseu_net-3.3;-lwx_baseu-3.3;-lwx_gtk3u_propgrid-3.3;-lwx_baseu_x
ml-3.3;-lwx_gtk3u_stc-3.3;-lwx_gtk3u_richtext-3.3 (found version "3.3.0")
-- Module support is disabled.
-- Version: 9.0.0
-- Build type: RelWithDebInfo
-- CXX_STANDARD: 17
-- Found wxWidgets:
-L/usr/local/lib;-pthread;;;-lwx_gtk3u_gl-3.3;-lwx_gtk3u_aui-3.3;-lwx_gtk3u_html-3.3;-lwx_gtk3u_core-3.3;-lwx_baseu_net-3.3;-lwx_baseu-3.3;-lwx_baseu_xml-3.3;-lwx_gtk3u_stc-3.
3 (found suitable version "3.3.0", minimum required is "3.0.0")
-- Configuring done
<snip>
[ 5%] Building CXX object
libs/kimath/CMakeFiles/kimath.dir/src/geometry/shape.cpp.o
[ 5%] Building CXX object
3d-viewer/3d_cache/sg/CMakeFiles/kicad_3dsg.dir/sg_shape.cpp.o
[ 5%] Building CXX object
libs/kimath/CMakeFiles/kimath.dir/src/geometry/shape_arc.cpp.o
[ 5%] Building CXX object
libs/kimath/CMakeFiles/kimath.dir/src/geometry/shape_collisions.cpp.o
In file included from /home/frodeg/projects/kicad/include/core/kicad_algo.h:31,
from
/home/frodeg/projects/kicad/libs/kimath/src/geometry/shape_arc.cpp:26:
/home/frodeg/projects/kicad/include/core/kicad_algo.h: In function
‘bool alg::within_wrapped_range(T, T, T, T)’:
/home/frodeg/projects/kicad/include/core/kicad_algo.h:130:5: error:
‘wxSTATEMENT_MACRO_BEGIN’ was not declared in this scope
130 | wxCHECK_MSG( __wrap > 0, false, wxT( "Wrap must be positive!" ) );
| ^~~~~~~~~~~
/home/frodeg/projects/kicad/include/core/kicad_algo.h:130:5: note: the
macro ‘wxSTATEMENT_MACRO_BEGIN’ had not yet been defined
In file included from /usr/local/include/wx-3.3/wx/version.h:16,
from /usr/local/include/wx-3.3/wx/defs.h:170,
from /usr/local/include/wx-3.3/wx/gdicmn.h:18,
from
/home/frodeg/projects/kicad/libs/kimath/include/math/vector2d.h:39,
from
/home/frodeg/projects/kicad/libs/kimath/include/geometry/circle.h:24,
from
/home/frodeg/projects/kicad/libs/kimath/src/geometry/shape_arc.cpp:27:
/usr/local/include/wx-3.3/wx/cpp.h:86: note: it was later defined here
86 | #define wxSTATEMENT_MACRO_BEGIN do {
|
/home/frodeg/projects/kicad/include/core/kicad_algo.h:130:5: error:
‘wxSTATEMENT_MACRO_END’ was not declared in this scope
130 | wxCHECK_MSG( __wrap > 0, false, wxT( "Wrap must be positive!" ) );
| ^~~~~~~~~~~
/home/frodeg/projects/kicad/include/core/kicad_algo.h:130:5: note: the
macro ‘wxSTATEMENT_MACRO_END’ had not yet been defined
/usr/local/include/wx-3.3/wx/cpp.h:87: note: it was later defined here
87 | #define wxSTATEMENT_MACRO_END } while ( (void)0, 0 )
|
[ 5%] Building CXX object
libs/kimath/CMakeFiles/kimath.dir/src/geometry/shape_file_io.cpp.o
/home/frodeg/projects/kicad/include/core/kicad_algo.h: In
instantiation of ‘bool alg::within_wrapped_range(T, T, T, T) [with T =
double]’:
/home/frodeg/projects/kicad/libs/kimath/src/geometry/shape_arc.cpp:611:37:
required from here
/home/frodeg/projects/kicad/include/core/kicad_algo.h:130:5: error:
‘alg::within_wrapped_range<double>(double, double, double,
double)::wxMAKE_UNIQUE_NAME wxDummyCheckStruct’ has incomplete type
130 | wxCHECK_MSG( __wrap > 0, false, wxT( "Wrap must be positive!" ) );
| ^~~~~~~~~~~

--
Frode Roxrud Gill

Vadim Zeitlin

unread,
Jan 13, 2023, 11:04:03 AM1/13/23
to wx-...@googlegroups.com
On Fri, 13 Jan 2023 00:45:19 +0100 Frode Roxrud Gill wrote:

FRG> On Fri, 13 Jan 2023 at 00:00, Vadim Zeitlin <va...@wxwidgets.org> wrote:
FRG> >
FRG> > On Thu, 12 Jan 2023 23:45:06 +0100 Frode Roxrud Gill wrote:
FRG> >
FRG> > FRG> For reasons, I am currently building kicad@master against
FRG> > FRG> wxWidgets@master, and it fails miserably.
FRG> >
FRG> > Could you please show the full compiler command line and the (first few)
FRG> > errors?
FRG>
FRG> On Debian Testing, wxWidgets is compiled with `make -j 6` after
FRG> running `../../configure --with-gtk=3 --enable-threads
FRG> --enable-secretstore --enable-exceptions --enable-stl
FRG> --enable-std-containers --enable-debug --with-opengl --with-sdl
FRG> --disable-compat30`

Please note that many options above (all except --enable-stl and
--enable-std-containers, I think) are the defaults and don't need to be
specified. This doesn't change anything for the problem at hand, of course,
but would just simplify your command line.

FRG> In file included from /home/frodeg/projects/kicad/include/core/kicad_algo.h:31,
FRG> from
FRG> /home/frodeg/projects/kicad/libs/kimath/src/geometry/shape_arc.cpp:26:
FRG> /home/frodeg/projects/kicad/include/core/kicad_algo.h: In function
FRG> ‘bool alg::within_wrapped_range(T, T, T, T)’:
FRG> /home/frodeg/projects/kicad/include/core/kicad_algo.h:130:5: error:
FRG> ‘wxSTATEMENT_MACRO_BEGIN’ was not declared in this scope

OK, thanks, so the problem is in a KiCad file and not wx/debug.h itself
and I understand it now: this header includes wx/debug.h and nothing else.
This used to work but was broken in master by 0f6c54cdb6 (Define
__WXFUNCTION__ as __func__ and don't use it any more, 2022-11-11) which
mistakenly removed wx/cpp.h inclusion from wx/debug.h as I thought it was
really necessary just for __WXFUNCTION__, which is not used any longer.

The solution is indeed to just restore this include, done now in
5f6fe1c71b (Make wx/debug.h included as first wx header compile again,
2023-01-13).

Thanks for reporting this,
VZ
Reply all
Reply to author
Forward
0 new messages