Red Hat Bugzilla – Bug 980270
namespace pollution with #define interface in mingw rpc.h
Last modified: 2013-08-03 15:37:15 EDT
Description of problem:
When cross-compiling for mingw, and attempting to use the identifier 'interface' (which is reserved for the user according to C99), compilation fails under mingw. While trying to cross-compile libvirt, I ended up with failed compilation where dbus tried to use 'interface' as a parameter name in a function prototype, but where an earlier '#define interface ...' in the system rpc.h caused syntax failures. Although I noticed it with libvirt, the case below is stripped down to the bare minimum for easier testing.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. cat foo.c
2. i686-w64-mingw32-gcc -c \
-I /usr/i686-w64-mingw32/sys-root/mingw/include/dbus-1.0 \
-I /usr/i686-w64-mingw32/sys-root/mingw/lib/dbus-1.0/include \
3. cat bar.c
4. i686-w64-mingw32-gcc -c bar.c
1. #include <rpc.h>
2. In file included from /usr/i686-w64-mingw32/sys-root/mingw/include/dbus-1.0/dbus/dbus-connection.h:32:0,
/usr/i686-w64-mingw32/sys-root/mingw/include/dbus-1.0/dbus/dbus-message.h:74:58: error: expected ';', ',' or ')' before 'struct'
/usr/i686-w64-mingw32/sys-root/mingw/include/dbus-1.0/dbus/dbus-message.h:80:58: error: expected ';', ',' or ')' before 'struct'
/usr/i686-w64-mingw32/sys-root/mingw/include/dbus-1.0/dbus/dbus-message.h:111:58: error: expected ';', ',' or ')' before 'struct'
/usr/i686-w64-mingw32/sys-root/mingw/include/dbus-1.0/dbus/dbus-message.h:116:58: error: expected ';', ',' or ')' before 'struct'
/usr/i686-w64-mingw32/sys-root/mingw/include/dbus-1.0/dbus/dbus-message.h:149:58: error: expected ';', ',' or ')' before 'struct'
/usr/i686-w64-mingw32/sys-root/mingw/include/dbus-1.0/dbus/dbus-message.h:153:58: error: expected ';', ',' or ')' before 'struct'
3. #include <rpc.h>
4. bar.c:2:0: warning: "interface" redefined [enabled by default]
In file included from /usr/i686-w64-mingw32/sys-root/mingw/include/oleidl.h:7:0,
/usr/i686-w64-mingw32/sys-root/mingw/include/rpc.h:12:0: note: this is the location of the previous definition
rpc.h should be namespace-clean, and should not leave 'interface' defined to interfere with subsequent valid C99 use of this identifier.
Yes, it could also be argued that dbus shouldn't be using the name 'interface' in its header prototypes, so I'll file a bug there, too.
(In reply to Eric Blake from comment #0)
> Additional info:
> Yes, it could also be argued that dbus shouldn't be using the name
> 'interface' in its header prototypes, so I'll file a bug there, too.
bug 980278 for that argument
I'm aware of the issue and I've also got hit by it on multiple occasions (as can be seen at https://bugzilla.gnome.org/show_bug.cgi?id=656402). However, the keyword 'interface' is a reserved keyword on Windows environments according to MSDN: http://msdn.microsoft.com/en-us/library/vstudio/2kb28261.aspx
Therefore I can't fix this in the mingw-w64 headers. If you still wish to pursue this issue I would recommend you to contact the upstream mingw-w64 developers and try to get it resolved there.
For downstream packages (like dbus) I would recommend to avoid using the 'interface' keyword in public headers. For this you've already created a separate bug report so I'll close this one.