-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add extern “C” block to header files #533
Conversation
Visit the preview URL for this PR (updated for commit 04f5e6b): https://golioth-firmware-sdk-doxygen-dev--pr533-add-cpp-suppor-vt4iqsxd.web.app (expires Wed, 10 Jul 2024 15:50:10 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: a9993e61697a3983f3479e468bcb0b616f9a0578 |
dc1c146
to
2a0d019
Compare
Code Coverage
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get why include/golioth/*.h
files need that. But how about src/*.h
? Those are private and should not be built with C++ compiler.
I agree @mniestroj and was debating with myself whether to add it to |
src/coap_blockwise.h
Outdated
@@ -3,6 +3,12 @@ | |||
* | |||
* SPDX-License-Identifier: Apache-2.0 | |||
*/ | |||
|
|||
#ifdef __cplusplus |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this also required in the private headers? Or only in the public headers? These headers in src/
aren't available to user applications, so they will only be included by C files, not C++.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll remove it from the private headers in src/
IMO it does hurt :) Any additional code that is not used is a dead code. Dead code not tested and potentially not working. Even if that is only so small, So I opt for removing it from private headers. |
By adding extern "C" block to header files, we avoid linking problems when building C++ applications that come from name mangling since C++ supports function overloading. Signed-off-by: Marko Puric <marko@golioth.io>
2a0d019
to
04f5e6b
Compare
@sam-golioth, @mniestroj removed from the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @MarkoPura!
By adding an extern "C" block to header files, we avoid linking problems when building C++ applications that come from name mangling since C++ supports function overloading.