lunarmodules / luafilesystem

LuaFileSystem is a Lua library developed to complement the set of functions related to file systems offered by the standard Lua distribution.
https://lunarmodules.github.io/luafilesystem/
MIT License
900 stars 291 forks source link

Add explicit cast to char* #164

Closed eliasdaler closed 9 months ago

eliasdaler commented 1 year ago

When I compile Lua as C++ (and therefore need to compile lfs as C++ as well), GCC says this:

luafilesystem/src/lfs.c:1068:28: error: invalid conversion from ‘void*’ to ‘char*’ [-fpermissive]
 1068 |     char *target2 = realloc(target, size);
      |                     ~~~~~~~^~~~~~~~~~~~~~
      |                            |
      |                            void*

To fix this, explicit cast to char* is needed. (lfs compiles as C++ and works well after this patch)

P.S. here is why I compile Lua as C++

hishamhm commented 9 months ago

oops, sorry, I was reviewing PRs top-to-bottom and I just merged another one which implements the same change! Thank you for the contribution, regardless!