axmolengine / axmol

Axmol Engine – A Multi-platform Engine for Desktop, XBOX (UWP) and Mobile games. (A fork of Cocos2d-x-4.0)
https://axmol.dev
MIT License
922 stars 205 forks source link

VS2019: thirdparty\xxhash: Cannot open include file: 'stdalign.h': No such file or directory #991

Closed aismann closed 1 year ago

aismann commented 1 year ago

VS2019 64bit build (32bit not tested)

Steps to Reproduce:

  1. build axmol\thirdparty\xxhash Build started... 1>------ Build started: Project: xxhash, Configuration: Debug x64 ------ 1>xxhash.c 1>...n\axmol\thirdparty\xxhash\xxhash.h(1009,1): fatal error C1083: Cannot open include file: 'stdalign.h': No such file or directory 1>Done building project "xxhash.vcxproj" -- FAILED. ========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========

Can anybody check it too? VS2019 64bit build shows error above. VS2022 64bit build works correct.

solan-solan commented 1 year ago

I can confirm the issue on VS2019 64bit

FlexTheProgrammer commented 1 year ago

I get the same error when running with:

aismann commented 1 year ago

get the same error when running with: axmol version: Latest Microsoft Visual Studio Community 2022 (64-bit) - Version 17.4.3

Works here on 2022 (64bit): @FlexTheProgrammer can you try it again? Microsoft Visual Studio Community 2022 (64-bit) - Version 17.4.3

  1. Clone latest axmol dev https://github.com/axmolengine/axmol/commit/7d2166fb31c3d7412bc76d9623c0c3536bc0d398) (create a new folder)
  2. Create the Visual Studio solution (cmake -S . -B build -G "Visual Studio 17 2022" -A x64)
  3. Build any of the test projects (msbuild .\build\axmol.sln -target:cpp_tests -maxCpuCount) => xxhash.lib was build without an error.

Works NOT on VS2019 (64bit) Tried it also with VS2019 (Professional) - Version 16.11.22 (Same steps as above (but for 2019 64bit "of course!") Result: Cannot open include file: 'stdalign.h': No such file or directory

aismann commented 1 year ago

Maybe a solution: I found this: https://github.com/raysan5/raylib/issues/2762

image

and here are the code snippet from miniaudio.h:

#if !defined(_MSC_VER) && defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
    #include <stdalign.h>
    #define MA_ATOMIC(alignment, type)            alignas(alignment) type
#else
    #if defined(__GNUC__)
        /* GCC-style compilers. */
        #define MA_ATOMIC(alignment, type)        type __attribute__((aligned(alignment)))
    #elif defined(_MSC_VER) && _MSC_VER > 1200  /* 1200 = VC6. Alignment not supported, but not necessary because x86 is the only supported target. */
        /* MSVC. */
        #define MA_ATOMIC(alignment, type)        __declspec(align(alignment)) type
    #else
        /* Other compilers. */
        #define MA_ATOMIC(alignment, type)        type
    #endif
#endif
aismann commented 1 year ago

The fix should be on xxHash/xxhash.h:

#if !defined(_MSC_VER) && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) /* >= C11 */
#  include <stdalign.h>
#  define XXH_ALIGN(n)      alignas(n)
#elif defined(__cplusplus) && (__cplusplus >= 201103L) /* >= C++11 */
/* In C++ alignas() is a keyword */
#  define XXH_ALIGN(n)      alignas(n)
#elif defined(__GNUC__)
#  define XXH_ALIGN(n)      __attribute__ ((aligned(n)))
#elif defined(_MSC_VER)
#  define XXH_ALIGN(n)      __declspec(align(n))
#else
#  define XXH_ALIGN(n)   /* disabled */
#endif
aismann commented 1 year ago

@halx99 That's the answer from xxhash developer, Any ideas? I'm off now image

halx99 commented 1 year ago

https://github.com/axmolengine/axmol/blob/dev/cmake/Modules/AXConfigDefine.cmake#L70

halx99 commented 1 year ago

https://github.com/axmolengine/axmol/blob/dev/cmake/Modules/AXConfigDefine.cmake#L70

We already set C11 in cmake, and the ci tests works, will fire a vs2019 gh action to test it

halx99 commented 1 year ago

refer to: https://github.com/axmolengine/axmol/actions/runs/3826891569/jobs/6511043178

halx99 commented 1 year ago

It's caused by sdk version, in my machine, when use latest windows sdk 22620 works, I will test other sdks, maybe add tests windows sdk version to README

halx99 commented 1 year ago

confirmed, required windows sdk version: 10.0.22000+

halx99 commented 1 year ago

confirmed, required windows sdk version: 10.0.22000+

Or specific c99 standard by cmake -B build -DCMAKE_C_STANDARD=99 maybe works on older windows sdk

aismann commented 1 year ago

after downloading the latest axmol version 9dec342 it works.