I have the following code:
#include <iostream>
int array[10] = {
[2] = 200,
[5] = 500
};
int main() {
std::cout << "Hello World!\n";
std::cout << array[5];
return 0;
}
When I compile with g++ -std=c++11 -o main main.cpp
, I get the following error:
main.cpp:6:1: sorry, unimplemented: non-trivial designated initializers not supported
};
^
main.cpp:6:1: sorry, unimplemented: non-trivial designated initializers not supported
Is there any way to do this with g++? Clang works fine.
Aucun commentaire:
Enregistrer un commentaire