3

I'm going absolutely nuts here. I'm doing some C++ development on Windows and I have a namespace named 'interface':

namespace gd {
namespace interface {

}} // end namespace

However, there is a file named "objbase.h" that gets included no matter if I include "Windows.h" or "Wtypes.h", which contains a macro named 'interface'. This macro won't allow me to use the namespace name. Is there a feature in the Win32 API to disable the definition of the interface macro? If not, can someone think of a clever workaround to disabling it, without requiring too many mass changes in my code base?

void.pointer
  • 24,859
  • 31
  • 132
  • 243
  • @delnan I've thought of a wrapper include that does that for me, but if someone outside of my code (it's a library) uses windows.h directly, they will run into the same problem. It'd be a lot easier to disable it at the API level with some preprocessor definition – void.pointer Aug 07 '12 at 21:26

2 Answers2

9

If you really want to do this, you could #undef the interface macro.

I'd suggest, rather, not naming your namespace interface, since interface is as close to being a reserved word as you can get without actually being a reserved word. It's going to cause a great deal of confusion to have that namespace in use.

jwismar
  • 12,164
  • 3
  • 32
  • 44
1

It appears that you could also define WIN32_LEAN_AND_MEAN to avoid that objbase.h gets pulled in when including windows.h.

Community
  • 1
  • 1
Frerich Raabe
  • 90,689
  • 19
  • 115
  • 207