From 451bf10af8fe433c6b91c41de4a42f9d28b2b263 Mon Sep 17 00:00:00 2001 From: Jonathan Reichelt Gjertsen Date: Sun, 23 May 2021 00:44:12 +0200 Subject: [PATCH] Define `__STRING` for other compilers than MSVC in the host platform.h file Without this change, I get errors like the following: ``` C:\MinGW\bin\gcc.exe -DLIB_PICO_BIT_OPS=1 -DLIB_PICO_DIVIDER=1 -DLIB_PICO_PRINTF=1 -DLIB_PICO_STDIO=1 -DLIB_PICO_STDLIB=1 -DLIB_PICO_SYNC=1 -DLIB_PICO_SYNC_CORE=1 -DLIB_PICO_SYNC_CRITICAL_SECTION=1 -DLIB_PICO_SYNC_MUTEX=1 -DLIB_PICO_SYNC_SEM=1 -DLIB_PICO_TIME=1 -DLIB_PICO_UTIL=1 -DPICO_BOARD=\"pico\" -DPICO_BUILD=1 -DPICO_DEFAULT_UART_BAUD_RATE=921600 -DPICO_HARDWARE_TIMER_RESOLUTION_US=1000 -DPICO_NO_HARDWARE=1 -DPICO_ON_DEVICE=0 -DPICO_TIME_DEFAULT_ALARM_POOL_DISABLED=1 -I[...]/pico-sdk/src/common/pico_stdlib/include -I[...]/pico-sdk/src/host/hardware_gpio/include -I[...]/pico-sdk/src/common/pico_base/include -Igenerated/pico_base -I[...]/pico-sdk/src/boards/include -I[...]/pico-sdk/src/host/pico_platform/include -I[...]/pico-sdk/src/common/pico_bit_ops/include -I[...]/pico-sdk/src/host/hardware_uart/include -I[...]/pico-sdk/src/host/hardware_divider/include -I[...]/pico-sdk/src/common/pico_time/include -I[...]/pico-sdk/src/host/hardware_timer/include -I[...]/pico-sdk/src/common/pico_sync/include -I[...]/pico-sdk/src/host/hardware_sync/include -I[...]/pico-sdk/src/common/pico_util/include -I[...]/pico-sdk/src/common/pico_divider/include -I[...]/pico-sdk/src/common/pico_binary_info/include -I[...]/pico-sdk/src/host/pico_stdio/include -O3 -DNDEBUG -Wno-unused-parameter -Wall -Wextra -fdiagnostics-color=always -std=gnu11 -MD -MT app/CMakeFiles/pm_comm_uart.dir/C_/dt/pico-sdk/src/host/hardware_gpio/gpio.c.obj -MF app\CMakeFiles\pm_comm_uart.dir\C_\dt\pico-sdk\src\host\hardware_gpio\gpio.c.obj.d -o app/CMakeFiles/pm_comm_uart.dir/C_/dt/pico-sdk/src/host/hardware_gpio/gpio.c.obj -c [...]/pico-sdk/src/host/hardware_gpio/gpio.c [...]/pico-sdk/src/host/hardware_gpio/gpio.c:54:32: error: _Pragma takes a parenthesized string literal PICO_WEAK_FUNCTION_DEF(gpio_get) ^ In file included from [...]/pico-sdk/src/common/pico_base/include/pico.h:19, from [...]/pico-sdk/src/host/hardware_gpio/include/hardware/gpio.h:14, from [...]/pico-sdk/src/host/hardware_gpio/gpio.c:7: [...]/pico-sdk/src/host/pico_platform/include/pico/platform.h:60:52: error: unknown type name 'weak' #define PICO_WEAK_FUNCTION_DEF(x) _Pragma(__STRING(weak x)) ^~~~ [...]/pico-sdk/src/host/hardware_gpio/gpio.c:54:1: note: in expansion of macro 'PICO_WEAK_FUNCTION_DEF' PICO_WEAK_FUNCTION_DEF(gpio_get) ^~~~~~~~~~~~~~~~~~~~~~ ``` --- src/host/pico_platform/include/pico/platform.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/host/pico_platform/include/pico/platform.h b/src/host/pico_platform/include/pico/platform.h index da060a6a2..499bdf648 100644 --- a/src/host/pico_platform/include/pico/platform.h +++ b/src/host/pico_platform/include/pico/platform.h @@ -36,6 +36,10 @@ extern "C" { //int running_on_fpga() { return false; } extern void tight_loop_contents(); +#ifndef __STRING +#define __STRING(x) #x +#endif + #ifndef _MSC_VER #ifndef __noreturn #define __noreturn __attribute((noreturn)) @@ -77,10 +81,6 @@ extern void tight_loop_contents(); #define __CONCAT(x,y) x ## y #endif -#ifndef __STRING -#define __STRING(x) #x -#endif() - #define __thread __declspec( thread ) #define PICO_WEAK_FUNCTION_DEF(x) __pragma(comment(linker, __STRING(/alternatename:_##x=_##x##__weak)));