I have this main :
int main() {
std::size_t n{10000};
std::vector<int> A(n);
for (size_t k{0}; k < 10000; ++k) { // repeating the same task over and over again.
#pragma omp parallel default(shared)
{
#pragma omp for
for (size_t i = 0; i < n; ++i) {
A[i] = i;
}
}
}
return 0;
}
I have the following problem, the initialization with the list initializer (curly braces) does not work :
this works
for (size_t i = 0; i < n; ++i) {
A[i] = i;
}
this doesn't
for (size_t i{0}; i < n; ++i) {
A[i] = i;
}
do you have any idea why ? I have been told one should always initialize with curly braces, instead of = or normal braces ( ).
I use MinGW, on CLion and I fixed my CMake regarding OpenMP as:
FIND_PACKAGE(OpenMP REQUIRED)
if (OPENMP_FOUND)
set(CMAKE_C_FLAGS "${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()