简体   繁体   English

如何禁用Win32“接口”宏?

[英]How to disable win32 'interface' macro?

I'm going absolutely nuts here. 我要疯了。 I'm doing some C++ development on Windows and I have a namespace named 'interface': 我正在Windows上进行一些C ++开发,并且有一个名为“ 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'. 但是,无论我包含“ Windows.h”还是“ Wtypes.h”,都有一个名为“ objbase.h”的文件被包含在内,该文件包含一个名为“ 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? Win32 API中是否有一项功能可以禁用接口宏的定义? If not, can someone think of a clever workaround to disabling it, without requiring too many mass changes in my code base? 如果没有,那么有人可以在不需要对我的代码库进行太多更改的情况下想到禁用它的巧妙解决方法吗?

If you really want to do this, you could #undef the interface macro. 如果您确实要执行此操作,则可以#undef interface宏。

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. 我建议,而不是命名您的名称空间interface ,因为interface尽可能接近保留字,而实际上却不是保留字。 It's going to cause a great deal of confusion to have that namespace in use. 使用该名称空间会引起很多混乱。

看来您还可以定义WIN32_LEAN_AND_MEAN以避免在包含windows.h时将objbase.h拖入。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM