Initializer list not working xCode 4.4
-
30-06-2021 - |
Question
I'm trying to use an initializer list in XCode 4,
struct Vector2f
{
float x,y;
Vector2f():x(0.f),y(0.f){}
Vector2f( float ix, float iy ):x(ix),y(iy){}
} ;
But I'm getting 7 compiler errors,
So it looks like it thinks I'm doing some "bit-field" business, but I'm trying to use an initializer list!
The code file is marked as "C++ header" in the file properties, but it seems it's compiling as C?
Solution
Oh, I see. The file that was including this C++ source was a .m
file -- ie it was being compiled as "Objective-C".
Renaming the #include
ing file to .mm
changes it's compilation mode to Objective-C++, then the compilation of the Vector2f
C++ class is successful.
- The other error I got (when I changed
struct Vector2f
toclass Vector2f
)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow