SanderMertens / flecs

A fast entity component system (ECS) for C & C++

Home Page:https://www.flecs.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compilation failed with errors when declaring 'free' as a macro.

JKot-Coder opened this issue · comments

commented

Compile this line (include\flecs\addons\cpp\delegate.hpp(222,17):

    // A function that can be used as a callback to free a delegate
    static void free(void *obj) {
        _::free_obj<each_delegate>(static_cast<each_delegate*>>>(obj));
    }

terminates with an error
error C2059: syntax error: 'constant'
If free is declared as a macro.

Reproduce:

#include <cstdlib>
#define free(p) std::free(p) 
#include "flecs.h"

Defining free as a macro is a common technique for overriding allocators.
_CRTDBG_MAP_ALLOC declares free as a macro
mimalloc-override.h declares free as a macro
etc.

Since this is only one method that conflicts with the free override I would ask you to revise its name to avoid conflicts.
Thank you.