mardi 6 octobre 2020

Compiler does not recognize constructor for std::vector

I want to initialize a std::vector to have a specific length. in the .hpp file I use

#include <vector>

std::vector<double> pressure (4,0); //vector 4 elements = 0

But I get the error:

error: expected identifier before numeric constant
std::vector<double> pressure(4,0);
                             ^
error: expected ',' or '...' before numeric constant

I read that this might be due to not using C++11 but I specify in my makefile

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_FLAGS_RELEASE "-O3")

I am compiling on a raspberry 4, g++ version is 8.3

Aucun commentaire:

Enregistrer un commentaire