![]() |
|
Rule about extern "C" and missing exceptions - Printable Version +- MISRA Discussion Forums (https://forum.misra.org.uk) +-- Forum: MISRA C++ (https://forum.misra.org.uk/forumdisplay.php?fid=18) +--- Forum: MISRA C++:2023 guidelines (https://forum.misra.org.uk/forumdisplay.php?fid=188) +---- Forum: 4.6 Basic concepts (https://forum.misra.org.uk/forumdisplay.php?fid=192) +---- Thread: Rule about extern "C" and missing exceptions (/showthread.php?tid=1768) |
Rule about extern "C" and missing exceptions - kth - 04-05-2026 Currently, MISRA C++:2023 mentions "extern C" as part of the following rules:
However, until now there is no rule provided that limits the keywords etc. can be "safely" used inside of an extern "C" block. Wouldn't that be helpful? Examples:
What about exceptions for extern "C" in the rules
Code example (https://godbolt.org/z/EG7Y9dxdh): Code: // some header.h - shared between C and C++RE: Rule about extern "C" and missing exceptions - misra cpp - 08-05-2026 extern "C" only affects linkage, and MISRA C++:2023 rules do not place any limits on their contents. The intention of 6.0.3 is to allows extern "C" to be used at global scope so that use can be made to declarations/definitions in headers from other C-compatible languages. There is an expectation that they will not be used to add objects at global scope that would otherwise be disallowed by 6.0.3. The wording of this rule is under review for a future version, to see if it needs to be more explicit what is allowed in an extern "C" block. |