Fix MSVC compilation error with openMP
Fix MSVC compilation error with openMP https://learn.microsoft.com/en-us/cpp/error-messages/compiler-errors-2/compiler-error-c3015?view=msvc-170
Besides, with this PR, openMP can also be disabled on windows paltform with 'NO_OMP=1' in makefile.
Not following exactly - are you saying the current code generates a C3015?
Not following exactly - are you saying the current code generates a C3015?
yes, in my evironment with MSVC, it did. After this modification, this error disappeared.
Our Windows CI and all current Windows builds are passing. What version of MSVC are you using? Please run: Cl /Bv. Also, what options are you using with Make?
Our Windows CI and all current Windows builds are passing. What version of MSVC are you using? Please run: Cl /Bv. Also, what options are you using with Make?
Well, I configured this project with visual studio 2022, with MSVC 19.39.33523.0. I copyed all the c_flags and ld_flags from Makefile. Then I encounterd this error (C3015).
As you suggested, this time I tried the CI's way of building, which employs an external make.exe program. Yes, it succeeded. I don't know what causes this difference.
Besides, to my knowlege, putting declaration of varariables which have possible impact on OMP before the '#pragma omp parallel' macro could be much more safe without other drawbacks.
Glad it works for you now when using make and the Makefile!
As far as the other changes, let's discuss those over in the Issues area. Microsoft does have a compiler bug with OpenMP 5.2 support which I've filed with them.
I'm not 100% sure, but I thought putting the declarations in front of the openmp statements would actually totally break this code. Aren't variables from outside the parallel region automatically shared?
I'm not 100% sure, but I thought putting the declarations in front of the openmp statements would actually totally break this code. Aren't variables from outside the parallel region automatically shared?
Thx for pointing out this. I checked the OMP usesage and found that I did have a misunderstanding of the memory model. declarations in front of the openmp statements will be implicitly handled as shared vars, not private. Adding the private(var) statement will make those vars private.
I have already fix the codes.