std::aligned_alloc() and ms-windows
Dear all,
The current gmshfem does not compile with mingw.
One reason is that std::aligned_alloc()
is apparently not compatible with ms-windows internals [1]!
The problem seems to affect msvc[1, 2] as well.
One bypass is to call _aligned_malloc()
and _aligned_free()
[3].
That works with mingw (tested) and apparently with msvc >= 2015 (untested).
In its current form, the merge request replaces the std::aligned_alloc()
calls with a macro.
This macro is _aligned_malloc()
with a win32 compiler and std::aligned_alloc()
otherwise.
The same goes for free()
.
One could also do it at runtime, but I don't know how critical function/executionTree/FunctionAllocator.cpp
is.
By the way, the CMakeLists
manipulates WIN32
, but that's an internal variable of cmake [4].
I suggest to use HAVE_WIN32
instead (also in this MR).
There's another unrelated problem with MessageModificator
and ms-win, but that will be in another MR ;).
Cheers, Nicolas.
[1] https://stackoverflow.com/questions/62962839/stdaligned-alloc-missing-from-visual-studio-2019
[2] !!! https://visualstudio.microsoft.com/vs/pricing-details/ !!!