Handmade Hero»Forums»Code
Jeff Buck
28 posts
handmade.cpp OS X compile problems due to size_t
A few days ago, Casey added a size_t type declaration for memory_index to handmade_platform.h. For those of us porting to other platforms, this breaks the compile of handmade.cpp.

On Windows, size_t is defined in crtdefs.h, which stdint.h includes. On OS X (and most Unix-y platforms), size_t isn't defined via stdint.h.

An easy way to fix this would be to also #include <stddef.h> in handmade_platform.h. This is harmless under Windows and will solve the OS X/Linux compile issue. Or alternatively, if you're willing to make a reasonable assumption about the values of memory_index, you could change its type from size_t to uint64 like we did with the semantically similar PermanentStorageSize/TransientStorageSize declarations.

-Jeff
Jeff Buck
28 posts
handmade.cpp OS X compile problems due to size_t
Whoops, looks like nxsy posted the same problem while I was typing mine up. At least we recommended the same solution. 8^)
Karl Kirch
18 posts
handmade.cpp OS X compile problems due to size_t
Can confirm as well.
Jeff Buck
28 posts
handmade.cpp OS X compile problems due to size_t
You can temporarily avoid editing the golden handmade_platform.h file by adding this to the compiler flags in your Makefile or Xcode build settings for handmade.cpp:

1
  -Dsize_t=__darwin_size_t
Karl Kirch
18 posts
handmade.cpp OS X compile problems due to size_t
That does indeed work. Just added it to my dylib custom compile flags in case anyone was wondering...