Skip to content

Use of NDEBUG define in "pico/types.h" seems to be the wrong way round #255

Closed
@bpinball

Description

@bpinball

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:

#ifndef NDEBUG
typedef uint64_t absolute_time_t;
#else
typedef struct {
    uint64_t _private_us_since_boot;
} absolute_time_t;
#endif

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions