Skip to content

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

@GeLee-Q

Description

@GeLee-Q

文中说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编译器下有办法解决这个问题嘛。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions