I am migrating a C++ library from *nix to MSVC.
The code has a function declaration named interface()
. This function works well on GCC and Clang compilers but when I'm compiling the code using MSVC, it keeps telling me unknown-type unexpected.
After doing some research, I found out that the function name conflicts with a predefined macro of a Windows library in a file named combaseapi.h
.
The definition looks like this:
#define interface __STRUCT__
I tried to add #undef interface
in the files that were complaining about the error and everything works fine.
However, there are several files that call and have definitions using this function name. I can declare the #undef interface
in all of those files but it seems pretty dirty to me.
Is there any way that I can define that line only just once? I've tried to define it in a header file and include it. But the compiler keeps complaining about the function name is unexpected.