HI people,
First post here, please go easy on me :)
#include <iostream>
#include <array>
int main()
{
using namespace std;
array<int, 5> cppArr = {1,2,3,4,5}; //"missing braces.." error and unresolved symbol highlight
return 0;
}
With "-pedantic -Wall -Werror" specified, compiling the above snippet in eclipse (using cygwin or minGW) would give me an warning/error along the lines of
error: missing braces around initializer for 'std::array<int, 5u>::value_type [5] {aka int [5]}' [-Werror=missing-braces]
Adding another pair of braces solves the problem:
array<int, 5> cppArr = {{1,2,3,4,5}};
As far as i know the first version of the code is correct and it seems to compile fine under Xcode and VS2012 without giving me the message (although im still playing with the warning settings in both Xcode and VS2012).
It would be great if anyone can show me what is wrong with my code snippet.
Another problem that also comes up in netbeans and eclipse is when i declare a C++ standard array like the code snippet, the word array would get highlighted with the following messges:
NetBeans:
unable to resolve indentifier array
Eclipse:
Symbol 'array' could not be resolved
The messages dont affect build, and the IDE's would happily compile the codes and run it.
The highlights and the messages only appear in NetBeans and Eclipse and not VS2012 and Xcode.
Again, i do not understand what they mean, so it would be much appreciated if anyone can explain them to me.
Thank you!
Ben