Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSVC std::aligned_alloc()函数无法使用 #3

Open
GeLee-Q opened this issue Feb 2, 2022 · 1 comment
Open

MSVC std::aligned_alloc()函数无法使用 #3

GeLee-Q opened this issue Feb 2, 2022 · 1 comment

Comments

@GeLee-Q
Copy link

GeLee-Q commented Feb 2, 2022

文中说aligned_alloc 并未被MSVC支持,但改用其 _aligned_malloc使用MSVC编译仍然失败;

在C++ 17中,但是使用MIngW仍然没法编译成功aligned_alloc ,编译成功了_aligned_malloc

namespace detail {
    void* allocate_aligned_memory(size_t align, size_t size) {
//        return std::aligned_alloc(align, size);
        return _aligned_malloc(size, align);
    }


    void deallocate_aligned_memory(void* ptr) noexcept {
//        std::free(ptr);
        _aligned_free(ptr);
    }
}

请问小彭老师,在MSVC编译器下有办法解决这个问题嘛。

@archibate
Copy link
Contributor

#ifdef _MSC_VER
return _aligned_malloc
#else
return std::aligned_alloc
#endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants