auto_init_recursive_mutex() fails to compile in C++ 10 #874

Closed
opened 2022-06-20 10:56:46 -05:00 by earlephilhower · 1 comment
earlephilhower commented 2022-06-20 10:56:46 -05:00 (Migrated from github.com)

Using g++ 10.3 against the devel or master branch of the SDK , the macro auto_init_recursive_mutex(xxx) generates a compile-time error:

/home/earle/Arduino/hardware/pico/rp2040//pico-sdk/src/common/pico_sync/include/pico/mutex.h:292:116: error: expected primary-expression before '.' token
  292 | #define auto_init_recursive_mutex(name) static __attribute__((section(".mutex_array"))) recursive_mutex_t name = { .core.spin_lock = (spin_lock_t *)1 /* marker for runtime_init */ }
      |                                                                                                                    ^
/home/earle/Arduino/sketch_jun20a/sketch_jun20a.ino:1:1: note: in expansion of macro 'auto_init_recursive_mutex'
    1 | auto_init_recursive_mutex(test);
      | ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/earle/Arduino/sketch_jun20a/sketch_jun20a.ino:1:27: warning: 'test' defined but not used [-Wunused-variable]
    1 | auto_init_recursive_mutex(test);
      |                           ^~~~
/home/earle/Arduino/hardware/pico/rp2040//pico-sdk/src/common/pico_sync/include/pico/mutex.h:292:107: note: in definition of macro 'auto_init_recursive_mutex'
  292 | #define auto_init_recursive_mutex(name) static __attribute__((section(".mutex_array"))) recursive_mutex_t name = { .core.spin_lock = (spin_lock_t *)1 /* marker for runtime_init */ }
      |                                                                                                           ^~~~
exit status 1

Compiling in gcc (i.e. straight C) succeeds without error, so this is a C++ vs. C issue.

My g++ command-line options (cut down to interesting bits):

arm-none-eabi-g++ -c -Wall -Wextra -Werror=return-type -Wno-ignored-qualifiers -march=armv6-m -mcpu=cortex-m0plus -mthumb \
    -iprefix/home/earle/Arduino/hardware/pico/rp2040/ @/home/earle/Arduino/hardware/pico/rp2040/lib/platform_inc.txt \
    -std=gnu++17 -g test.cpp -o test.o

I've also tried at std=gnu++11 with the same error

Using `g++` 10.3 against the `devel` or `master` branch of the SDK , the macro `auto_init_recursive_mutex(xxx)` generates a compile-time error: ```` /home/earle/Arduino/hardware/pico/rp2040//pico-sdk/src/common/pico_sync/include/pico/mutex.h:292:116: error: expected primary-expression before '.' token 292 | #define auto_init_recursive_mutex(name) static __attribute__((section(".mutex_array"))) recursive_mutex_t name = { .core.spin_lock = (spin_lock_t *)1 /* marker for runtime_init */ } | ^ /home/earle/Arduino/sketch_jun20a/sketch_jun20a.ino:1:1: note: in expansion of macro 'auto_init_recursive_mutex' 1 | auto_init_recursive_mutex(test); | ^~~~~~~~~~~~~~~~~~~~~~~~~ /home/earle/Arduino/sketch_jun20a/sketch_jun20a.ino:1:27: warning: 'test' defined but not used [-Wunused-variable] 1 | auto_init_recursive_mutex(test); | ^~~~ /home/earle/Arduino/hardware/pico/rp2040//pico-sdk/src/common/pico_sync/include/pico/mutex.h:292:107: note: in definition of macro 'auto_init_recursive_mutex' 292 | #define auto_init_recursive_mutex(name) static __attribute__((section(".mutex_array"))) recursive_mutex_t name = { .core.spin_lock = (spin_lock_t *)1 /* marker for runtime_init */ } | ^~~~ exit status 1 ```` Compiling in `gcc` (i.e. straight C) succeeds without error, so this is a C++ vs. C issue. My g++ command-line options (cut down to interesting bits): ```` arm-none-eabi-g++ -c -Wall -Wextra -Werror=return-type -Wno-ignored-qualifiers -march=armv6-m -mcpu=cortex-m0plus -mthumb \ -iprefix/home/earle/Arduino/hardware/pico/rp2040/ @/home/earle/Arduino/hardware/pico/rp2040/lib/platform_inc.txt \ -std=gnu++17 -g test.cpp -o test.o ```` I've also tried at `std=gnu++11` with the same error
kilograham commented 2022-06-20 12:51:34 -05:00 (Migrated from github.com)

merged into develop

merged into develop
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-raspberrypi/pico-sdk#874
No description provided.