Use of NDEBUG define in "pico/types.h" seems to be the wrong way round #255
Labels
No labels
bazel
bluetooth
board settings
boot_stage2
bug
build
c++
can't reproduce
clang
clib-interface
cmsis
code cleanliness
code size
compiler version issues
cyw43_driver
debug
discussion
documentation
duplicate
dynamic_clock
elf2uf2
enhancement
errata
filesystem
flash layout
floating point
FreeRTOS
hardware_adc
hardware_claim
hardware_clocks
hardware_dma
hardware_exception
hardware_flash
hardware_gpio
hardware_i2c
hardware_irq
hardware_pio
hardware_pwm
hardware_rcp
hardware_rtc
hardware_spi
hardware_sync
hardware_uart
hardware_vreg
hardware_watchdog
hardware_xosc
help wanted
host
IAR
installation
invalid
linker scripts
lto
lwip
mbedtls
missing API
needs reporter detail
networking
newlib
newlib-multicore
non-c
non-cmake
non-gcc
openocd
orphan PR
OS integration
pico_async_context
pico_base
pico_binary_info
pico_flash
picolibc
pico_lwip
pico_malloc
pico_multicore
pico_printf
pico_runtime
pico_stdio
pico_stdio_usb
pico_sync
pico_time
pico_util
pioasm
port
question
review
review2
rtos interop
runtime init
static library
svd
test
tinyusb
vscode
wifi integration
wontfix
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-raspberrypi/pico-sdk#255
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The use of the NDEBUG (Not DEBUG) compiler definition in pico/types.h seems to be the wrong way round. E.g. in the code in types.h:
the first section defined as not NDEBUG (i.e. is debug code) seems to be code that should be used in release builds, and the NDEBUG section (marked as not debug code) is the code that should be used in debug builds to detect misuse of the time types.
This causes the release build usage of time/clock functions to run more slowly than in debug builds, as well as causing the incorrect usage of the absolute_time_t type to be detected only in a release build.
On a side note, the overhead of having the time functions have to dereference a structure (when this issue is fixed) in debug code is considerable e.g. in tight audio PWM loops.
Hmmm, that header file also says "It is equivalent to uint64_t in release builds." so maybe that implies that all the
#ifndef NDEBUGlines in that file ought to be#ifdef NDEBUG? 🤷♂️ 🤷oops; that is backwards...
on a side note, why on earth would you do PWM audio in a timing loop; there are perfectly good timer paced DMAs :-)
Thanks everyone. I know it's the gcc way, but that double negative of
#ifndef NDEBUGconfused me for a while. Don't worry Graham, it's just experimental PWM code, honest! Will refactor to a DMA based solution.@kilograham This simple patch results in a clean
Releasebuildbut results in a large swath of warnings when doing a
Debugbuild:Ha ha! Btw thanks for the good catch.. that was wasting precious time :-)
Fixed by #260