spnda / fastgltf

A modern C++17 glTF 2.0 library focused on speed, correctness, and usability
https://fastgltf.readthedocs.io/v0.8.x/
MIT License
315 stars 48 forks source link

Compile errors on Windows #81

Closed julcst closed 6 days ago

julcst commented 1 week ago

I get a lot of compile errors compiling fastgltf with Visual Studio 2022 on Windows. On Linux with clang I had non of these issues. Maybe you can help me understand them I am relatively new to C++:

[build] C:\Users\User\Desktop\binrc\build\_deps\fastgltf-src\include\fastgltf\util.hpp(179,35): error C2988: unrecognizable template declaration/definition
[build] C:\Users\User\Desktop\binrc\build\_deps\fastgltf-src\include\fastgltf\util.hpp(179,35): error C2059: syntax error: 'const'
[build] C:\Users\User\Desktop\binrc\build\_deps\fastgltf-src\include\fastgltf\util.hpp(179,35): error C2059: syntax error: ')'
[build] C:\Users\User\Desktop\binrc\build\_deps\fastgltf-src\include\fastgltf\util.hpp(179,72): error C2143: syntax error: missing ';' before '{'
[build] C:\Users\User\Desktop\binrc\build\_deps\fastgltf-src\include\fastgltf\util.hpp(179,72): error C2447: '{': missing function header (old-style formal list?)
[build] C:\Users\User\Desktop\binrc\build\_deps\fastgltf-src\include\fastgltf\util.hpp(189,35): error C2988: unrecognizable template declaration/definition
[build] C:\Users\User\Desktop\binrc\build\_deps\fastgltf-src\include\fastgltf\util.hpp(189,35): error C2059: syntax error: 'const'
[build] C:\Users\User\Desktop\binrc\build\_deps\fastgltf-src\include\fastgltf\util.hpp(189,35): error C2059: syntax error: ')'
[build] C:\Users\User\Desktop\binrc\build\_deps\fastgltf-src\include\fastgltf\util.hpp(189,72): error C2143: syntax error: missing ';' before '{'
[build] C:\Users\User\Desktop\binrc\build\_deps\fastgltf-src\include\fastgltf\util.hpp(189,72): error C2447: '{': missing function header (old-style formal list?)
...

They all seem to originate from these functions in util.hpp:

    FASTGLTF_EXPORT template <typename T>
#if FASTGLTF_HAS_CONCEPTS
    requires requires (T t) {
        { t > t } -> std::same_as<bool>;
    }
#endif
    [[nodiscard]] constexpr const T& max(const T& a, const T& b) noexcept {
        return (a > b) ? a : b;
    }

    FASTGLTF_EXPORT template <typename T>
#if FASTGLTF_HAS_CONCEPTS
    requires requires (T t) {
        { t < t } -> std::same_as<bool>;
    }
#endif
    [[nodiscard]] constexpr const T& min(const T& a, const T& b) noexcept {
        return (a < b) ? a : b;
    }

and std::numeric_limits<>::max()

julcst commented 1 week ago

Nvm it was cuda_runtime.hpp overriding max and min, changing include order fixed this. I hate the preprocessor

spnda commented 6 days ago

yeah, Windows.h defines a bunch of crap which is just legacy C bullshit. If you find any more issues don't hesitate to let me know, but perhaps don't paste the entire log output :D