What is the reason for the assertions in system/Platform.h ?

Issue #240 wontfix
Frank Drop created an issue

In blaze/system/Platform.h I find the following three assertions:

BLAZE_STATIC_ASSERT( !BLAZE_WIN64_PLATFORM || ( !BLAZE_MINGW32_PLATFORM && !BLAZE_MINGW64_PLATFORM ) );
BLAZE_STATIC_ASSERT( !BLAZE_MINGW32_PLATFORM || ( !BLAZE_WIN64_PLATFORM && !BLAZE_MINGW64_PLATFORM ) );
BLAZE_STATIC_ASSERT( !BLAZE_MINGW64_PLATFORM || ( !BLAZE_WIN64_PLATFORM && !BLAZE_MINGW32_PLATFORM ) );

When compiling a project involving blaze with MSYS2 on MinGW64, these assertions fail, because all three defines are true. When out commenting these three assertions, the program compiles fine and is fully functional. I was wondering why these checks are implemented.

Comments (3)

  1. Klaus Iglberger

    Hi Frank!

    These static assertions document our expectations on the platforms. Our current expectations are that only one of these three settings can be true at any time. Apparently you have found a system that is both a 32-bit and a 64-bit system, which sounds strange to us (at least unexpected).

    Please feel free to provide a pull request to enable the use of MYS2. The above settings are used for several system depending implementations: <math/Infinity.h> and <util/Limits.h>(both because ofsize_tandptrdiff_t) and<util/Memory.h>``` (for the platform-specific allocation of aligned memory). All of these need to be tested on all involved platforms (i.e. MinGW, Win64 and MSYS2) before a pull request can be accepted. Thanks,

    Best regards,

    Klaus!

  2. Klaus Iglberger

    Hi Frank!

    I assume the question has been answered. If you still decide to provide a pull request, please refer back to this issue. Thanks,

    Best regards,

    Klaus!

  3. Thomas Castro

    Hi,

    I was compiling a project and encountered the same assertions failing. I investigated a little about how the Pre-defined compiler macros work (here for compiler especific macros/ here for OS specific macros) and encountered that “__MINGW32__“ is defined whether I’m using Mingw32 of Mingw64 (32bit or 64bit). Also as far as I know MSYS2 uses Mingw64, In my case. I’m using niXman posix binaries. With that knowledge these assertions will always fail because all are set to 1 if I am using Mingw64.

    I have checked the headers you mentioned that uses the *_PLATFORM macros (Infinity.h, Limits.h and Memory.h).

    <util/Memory.h>:

    I think the intention with the macros on the use of _aligned_malloc() and __mingw_aligned_malloc() was to identify if the user was using MSVC, MinGW-w64 or MinGW-w32. The only issue that I see is that it first checks if WIN32 set to true then uses _aligned_malloc(). However it does not ensure the user is not using MinGW-w32 as it could be possible both were defined.

    Maybe in this case it is safer to have a macro indicating it is using MSVC compiler replacing the windows macros.

    <math/Infinity.h> and <util/Limits.h>:

    It just checks if I am at windows so I think this one is safe if the assertions changes. For clarity I checked that ptrdiff_t and size_t have the same sizes on both MSVC and MinGW-64 where the platform is 32 or 64.

    I’m new on this platform so I apologize if I was not clear or any mistake on my side.

    Best regards,

    Tom.

  4. Log in to comment