assert can cause -Werror=implicit-function-declaration when NDEBUG is enabled
- Dominant language
- C
- Stars
- 4k
- Forks
- 1.7k
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 237
Description
The NuttX assert implementation is as follows when NDEBUG is defined
https://github.com/apache/nuttx/blob/61a46ad39ef215213cb831d5b58834bf2a5a7ad0/include/assert.h#L103
Which can cause a `-Werror=implicit-function-declaration` when code assertion checks like this
```
#ifndef NDEBUG
static inline bool isokay(bool okay)
{
return okay
}
#endif
void foo()
{
assert(isokay(1))
}
```
When `NDEBUG` is defined the function `isokay` doesn't get declared but the assertion stills refers to it. Causing a `-Werror=implicit-function-declaration` error.
It seems that other implementations of assert() when NDEBUG is as follows
```
# define assert(f) ((void)(1))
```
Avoiding the `-Werror=implicit-function-declaration` error.
Contributor guide
Assessment
This issue has not been assessed yet.