ARM GCC not recognizing unsigned int types inside of Playdate SDK code

,

Hey there!

A few months ago I had started a little demo game project with the Playdate SDK. I'm trying to pick it back up, so I updated the SDK to the newest version (2.4.1) on my M1 MacBook Pro running Sonoma. I am using CMake to generate my build files with this command:

cmake -DCMAKE_TOOLCHAIN_FILE=/Users/uglyluigi/Developer/PlaydateSDK/C_API/buildsupport/arm.cmake -DCMAKE_C_COMPILER=arm-none-eabi-gcc

This is the content of my CMakeLists.txt:

cmake_minimum_required(VERSION 3.14)
set(CMAKE_C_STANDARD 11)

set(ENVSDK $ENV{PLAYDATE_SDK_PATH})
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_BUILD_TYPE Debug)

if (NOT ${ENVSDK} STREQUAL "")
	# Convert path from Windows
	file(TO_CMAKE_PATH ${ENVSDK} SDK)
else()
	execute_process(
			COMMAND bash -c "egrep '^\\s*SDKRoot' $HOME/.Playdate/config"
			COMMAND head -n 1
			COMMAND cut -c9-
			OUTPUT_VARIABLE SDK
			OUTPUT_STRIP_TRAILING_WHITESPACE
	)
endif()

if (NOT EXISTS ${SDK})
	message(FATAL_ERROR "SDK Path not found; set ENV value PLAYDATE_SDK_PATH")
	return()
endif()

set(CMAKE_CONFIGURATION_TYPES "Debug;Release")
set(CMAKE_XCODE_GENERATE_SCHEME TRUE)

# Game Name Customization
set(PLAYDATE_GAME_NAME ConspicuousFishing)
set(PLAYDATE_GAME_DEVICE ConspicuousFishing_SIM)

project(${PLAYDATE_GAME_NAME} C ASM)

FILE(GLOB SOURCES src/*.c src/entity/*.c)
FILE(GLOB HEADERS src/*.h src/entity/*.h)

if (TOOLCHAIN STREQUAL "armgcc")
	add_executable(${PLAYDATE_GAME_DEVICE} ${SOURCES} ${HEADERS})
else()
	add_library(${PLAYDATE_GAME_NAME} SHARED ${SOURCES} ${HEADERS})
endif()

include(${SDK}/C_API/buildsupport/playdate_game.cmake)

It successfully generates the build files.

When trying to build my project, which did not have this problem before, arm-none-eabi-gcc complains that code inside of the C API of the Playdate SDK makes references to int types that apparently do not exist. I think I have some sort of toolchain configuration issue because I can get this compiler to complain about the same thing on Windows. Running 'make' gives me this output (with a bunch of warnings about using void pointers clipped out):

[ 71%] Building C object CMakeFiles/ConspicuousFishing_SIM.dir/src/util.c.obj
/usr/local/bin/arm-none-eabi-gcc -DTARGET_EXTENSION=1 -DTARGET_PLAYDATE=1 -I/Users/uglyluigi/Developer/PlaydateSDK/C_API -g -std=gnu11 -Wall -Wno-unknown-pragmas -Wdouble-promotion -O2 -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -D__FPU_USED=1 -falign-functions=16 -fomit-frame-pointer -gdwarf-2 -fverbose-asm -ffunction-sections -fdata-sections -mword-relocations -fno-common -MD -MT CMakeFiles/ConspicuousFishing_SIM.dir/src/util.c.obj -MF CMakeFiles/ConspicuousFishing_SIM.dir/src/util.c.obj.d -o CMakeFiles/ConspicuousFishing_SIM.dir/src/util.c.obj -c /Users/uglyluigi/Developer/conspicuous_fishing/src/util.c
In file included from /Users/uglyluigi/Developer/conspicuous_fishing/src/util.c:4:
/Users/uglyluigi/Developer/PlaydateSDK/C_API/pd_api/pd_api_gfx.h:89:9: error: unknown type name 'uint8_t'
   89 | typedef uint8_t LCDPattern[16]; // 8x8 pattern: 8 rows image data, 8 rows mask
      |         ^~~~~~~
/Users/uglyluigi/Developer/PlaydateSDK/C_API/pd_api/pd_api_gfx.h:90:9: error: unknown type name 'uintptr_t'
   90 | typedef uintptr_t LCDColor; // LCDSolidColor or pointer to LCDPattern
      |         ^~~~~~~~~
In file included from /Users/uglyluigi/Developer/conspicuous_fishing/src/util.c:4:
/Users/uglyluigi/Developer/PlaydateSDK/C_API/pd_api/pd_api_gfx.h:157:83: error: unknown type name 'uint8_t'; did you mean 'wint_t'?
  157 |  void (*getBitmapData)(LCDBitmap* bitmap, int* width, int* height, int* rowbytes, uint8_t** mask, uint8_t** data);
      |                                                                                   ^~~~~~~
      |                                                                                   wint_t
/Users/uglyluigi/Developer/PlaydateSDK/C_API/pd_api/pd_api_gfx.h:157:99: error: unknown type name 'uint8_t'; did you mean 'wint_t'?
  157 |  void (*getBitmapData)(LCDBitmap* bitmap, int* width, int* height, int* rowbytes, uint8_t** mask, uint8_t** data);
      |                                                                                                   ^~~~~~~
      |                                                                                                   wint_t
/Users/uglyluigi/Developer/PlaydateSDK/C_API/pd_api/pd_api_gfx.h:170:45: error: unknown type name 'uint32_t'; did you mean 'wint_t'?
  170 |  LCDFontPage* (*getFontPage)(LCDFont* font, uint32_t c);
      |                                             ^~~~~~~~
      |                                             wint_t
/Users/uglyluigi/Developer/PlaydateSDK/C_API/pd_api/pd_api_gfx.h:171:51: error: unknown type name 'uint32_t'; did you mean 'wint_t'?
  171 |  LCDFontGlyph* (*getPageGlyph)(LCDFontPage* page, uint32_t c, LCDBitmap** bitmap, int* advance);
      |                                                   ^~~~~~~~
      |                                                   wint_t
/Users/uglyluigi/Developer/PlaydateSDK/C_API/pd_api/pd_api_gfx.h:172:46: error: unknown type name 'uint32_t'; did you mean 'wint_t'?
  172 |  int (*getGlyphKerning)(LCDFontGlyph* glyph, uint32_t glyphcode, uint32_t nextcode);
      |                                              ^~~~~~~~
      |                                              wint_t
/Users/uglyluigi/Developer/PlaydateSDK/C_API/pd_api/pd_api_gfx.h:172:66: error: unknown type name 'uint32_t'; did you mean 'wint_t'?
  172 |  int (*getGlyphKerning)(LCDFontGlyph* glyph, uint32_t glyphcode, uint32_t nextcode);
      |                                                                  ^~~~~~~~
      |                                                                  wint_t
/Users/uglyluigi/Developer/PlaydateSDK/C_API/pd_api/pd_api_gfx.h:176:2: error: unknown type name 'uint8_t'
  176 |  uint8_t* (*getFrame)(void); // row stride = LCD_ROWSIZE
      |  ^~~~~~~
/Users/uglyluigi/Developer/PlaydateSDK/C_API/pd_api/pd_api_gfx.h:177:2: error: unknown type name 'uint8_t'
  177 |  uint8_t* (*getDisplayFrame)(void); // row stride = LCD_ROWSIZE
      |  ^~~~~~~
/Users/uglyluigi/Developer/PlaydateSDK/C_API/pd_api/pd_api_gfx.h:192:2: error: expected specifier-qualifier-list before 'uint8_t'
  192 |  uint8_t (*getFontHeight)(LCDFont* font);
      |  ^~~~~~~
/Users/uglyluigi/Developer/conspicuous_fishing/src/util.c: In function 'alloc_bitmap_table':
/Users/uglyluigi/Developer/conspicuous_fishing/src/util.c:56:68: warning: passing argument 2 of 'pd->graphics->loadBitmapTable' from incompatible pointer type [-Wincompatible-pointer-types]
   56 |  LCDBitmapTable *table = pd->graphics->loadBitmapTable(table_path, &outerror);
      |                                                                    ^~~~~~~~~
      |                                                                    |
      |                                                                    char (*)[50]
/Users/uglyluigi/Developer/conspicuous_fishing/src/util.c:56:68: note: expected 'const char **' but argument is of type 'char (*)[50]'
make[2]: *** [CMakeFiles/ConspicuousFishing_SIM.dir/src/util.c.obj] Error 1
make[1]: *** [CMakeFiles/ConspicuousFishing_SIM.dir/all] Error 2
make: *** [all] Error 2

It looks like it is using the proper compiler and linking against the right things, but I get these very strange errors. I'm not a C toolchain expert by any means but every support article about a compiler saying that it can't recognize these types tells me to include some header which is not a solution for external code that I do not maintain. Obviously something is wrong with how my toolchain is configured, but I don't know where to go from here so I'd appreciate any guidance you could give me!

You don't need to add this -DCMAKE_C_COMPILER=arm-none-eabi-gcc. It may be picking the wrong compiler and not using the correct headers.