I'm facing a problem in Xcode with the operator
keyword. I have this in a header file (.h) but Xcode recognizes it as a keyword due to operator overloding in C++, even though I'm setting the file type as a default C header and not C++ header. The code I'm trying to compile is all written in C and the line of code i'm having problem is like this
struct foo {
int a;
int b;
...
char operator[80];
}
I'm stuck with this a while now. The reason for the operator to be used as a variable name is not in scope now becouse this is a cross plataform code that I can't change and is compilable in many other plataforms for low-level devices.
Any help will be appreciated.
operator
isn't the only C++-specific keyword). Figuring out how to compile as C is much better than working around the problem by changing the identifier - Keith Thompson 2012-04-04 20:39
How about if you used the pre-processor:
#define operator _operator
? Put the above in a header file that is read in before your header.
The file type that matters is the file you're including the header in. If you're trying to include this header in a C++ file then this error is expected and there's no way to use this header from C++. If you're already using it only in C files then I'm not sure off the top of my head what the issue could be.