Skip to content

Commit

Permalink
game_shared: include malloc.h on win32, otherwise use alloca.h
Browse files Browse the repository at this point in the history
alloca() is a nonstandard function, and its definition location depends on the platform.

Ideally, we test which header defines it, on Win32 it's malloc.h as per the documentation, on *nixes it's usually alloca.h, but sometimes it's even stdlib.h.

For now, just include alloca.h to fix building on macOS (thanks @FiEctro for the help!)
  • Loading branch information
a1batross authored and SNMetamorph committed Aug 11, 2024
1 parent 53c402b commit 2332f75
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions game_shared/utlmemory.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@

#include <stddef.h>
#include <string.h>
#ifdef _WIN32
#include <malloc.h>
#else // _WIN32
#include <alloca.h>
#endif // _WIN32
#include <new>

#define ALIGN_VALUE( val, alignment ) (( val + alignment - 1 ) & ~( alignment - 1 ))
Expand Down

0 comments on commit 2332f75

Please sign in to comment.