Closed thrimbor closed 4 years ago
Working on this uncovered a series of other issues with a C++ compile I will have to fix before I can submit it all.
_PDCLIB_Noreturn
(leading a function declaration) resolves to the C11 keyword _Noreturn
if, and only if, the compiler is running in C11 mode. This works in tandem with the header <stdnoreturn.h>
. This is not something you should have to touch.
There is the creatively named _PDCLIB_NORETURN
, which is trailing the same function declarations that _PDCLIB_Noreturn
is leading. This is actually the older construct, added before there even was a C11. It is configured in <_PDCLIB_config.h>
, to resolve to whatever your compiler needs to be informed that this function does, indeed, not return -- regardless of which mode it runs in. In the example platform, this is set to __attribute__(( noreturn ))
, which "does the right thing" for GCC.
For some reason this attribute was not set for the <stdlib.h>
functions. I might have removed it when I added the C11 construct, or never have added it, I don't know. I'll look into how that muckup came to happen at some later time.
Long story short, the latest version (in both SVN and git) should compile cleanly for C++.
The current code for
PDCLIB_Noreturn
seems to define it as an empty macro when building with a C++ compiler. This causeswarning: function declared 'noreturn' should not return [-Winvalid-noreturn]
warnings when building libc++, as it expectsabort()
, which is called in functions marked[[noreturn]]
, to come with the C++11[[noreturn]]
attribute.I experimented with adding the following code in line 59 of _PDCLIB_int.h:
It fixed the warnings in my tests while not negatively impacting compilation of other code.