When C++ bindings for libsigrok are enabled, cross-compilation for Windows currently fails because of a macro name conflict:
In file included from /home/user/mxe-git/usr/i686-w64-mingw32.static/include/windows.h:72:0, from /home/user/mxe-git/usr/i686-w64-mingw32.static/include/boost/detail/interlocked.hpp:27, from /home/user/mxe-git/usr/i686-w64-mingw32.static/include/boost/thread/win32/thread_primitives.hpp:18, from /home/user/mxe-git/usr/i686-w64-mingw32.static/include/boost/thread/win32/thread_data.hpp:11, from /home/user/mxe-git/usr/i686-w64-mingw32.static/include/boost/thread/thread_only.hpp:15, from /home/user/mxe-git/usr/i686-w64-mingw32.static/include/boost/thread/thread.hpp:12, from /home/user/mxe-git/usr/i686-w64-mingw32.static/include/boost/thread.hpp:13, from /home/user/sigrok-util/cross-compile/mingw/build/pulseview/pv/session.hpp:32, from /home/user/sigrok-util/cross-compile/mingw/build/pulseview/pv/storesession.cpp:25: /home/user/sr_mingw/include/libsigrokcxx/enums.hpp:153:32: error: expected unqualified-id before numeric constant static const Quantity * const DIFFERENCE; ^ In file included from /home/user/mxe-git/usr/i686-w64-mingw32.static/include/windows.h:71:0, from /home/user/mxe-git/usr/i686-w64-mingw32.static/include/boost/detail/interlocked.hpp:27, from /home/user/mxe-git/usr/i686-w64-mingw32.static/include/boost/thread/win32/thread_primitives.hpp:18, from /home/user/mxe-git/usr/i686-w64-mingw32.static/include/boost/thread/win32/thread_data.hpp:11, from /home/user/mxe-git/usr/i686-w64-mingw32.static/include/boost/thread/thread_only.hpp:15, from /home/user/mxe-git/usr/i686-w64-mingw32.static/include/boost/thread/thread.hpp:12, from /home/user/mxe-git/usr/i686-w64-mingw32.static/include/boost/thread.hpp:13, from /home/user/sigrok-util/cross-compile/mingw/build/pulseview/pv/session.hpp:32, from /home/user/sigrok-util/cross-compile/mingw/build/pulseview/pv/storesession.cpp:25: /home/user/sr_mingw/include/libsigrokcxx/enums.hpp:299:36: error: expected unqualified-id before numeric constant static const QuantityFlag * const RELATIVE; ^ The problem is RELATIVE and DIFFERENCE are replaced to integer constants by a preprocessor. Both macros are defined in windows-specific includes: wingdi.h: /* Coordinate Modes */ #define ABSOLUTE 1 #define RELATIVE 2 winuser.h: #define RT_RCDATA MAKEINTRESOURCE(10) #define RT_MESSAGETABLE MAKEINTRESOURCE(11) #define DIFFERENCE 11 One of possible solutions is to undefine these macros in each generated enum file, and another to rename enum values. This patch implements the former: diff --git a/bindings/cxx/enums.py b/bindings/cxx/enums.py index aed4212..5d7e50e 100644 --- a/bindings/cxx/enums.py +++ b/bindings/cxx/enums.py @@ -70,7 +70,11 @@ code = open(os.path.join(outdirname, 'enums.cpp'), 'w') swig = open(os.path.join(dirname, '../swig/enums.i'), 'w') for file in (header, code): - print("/* Generated file - edit enums.py instead! */", file=file) + print("/* Generated file - edit enums.py instead! */\n" + "#ifdef WIN32\n" + "#undef DIFFERENCE\n" + "#undef RELATIVE\n" + "#endif\n", file=file) # Template for beginning of class declaration and public members. header_public_template = """ This is a bit messy. Not as messy as WinAPIs macro naming, though. This (alongside with configure.ac fix) should fix Windows build. -- Vladislav Ivanov ------------------------------------------------------------------------------ Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ sigrok-devel mailing list sigrok-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sigrok-devel