Skip to content
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" for C linkage in C++ #53

Closed
wants to merge 1 commit into from

Conversation

MustafaYassin
Copy link

Added extern "C" to be linkable in C++ compilation.

@boraozgen
Copy link

Why not use extern "C" when including?

@armandas
Copy link

armandas commented Jun 14, 2021

Why not use extern "C" when including?

I believe it's a common sense for C libraries to add this to their headers. FreeRTOS kernel does it: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/6a84f2c1da0f8d9fd1946caa55a336ebacfeb392/include/FreeRTOS.h#L54

The benefits are:

  • Library works seamlessly with C and C++.
  • User don't have to waste time debugging cryptic linker errors.
  • Maintainers don't have to waste time telling the users to "wrap the include in extern "C"".

@MustafaYassin
Copy link
Author

The benefits include:

  • cleaner user code.
  • alignment with all other FreeRTOS headers.

@muneebahmed10
Copy link
Contributor

Hi @MustafaYassin,

Thank you for bringing this to our attention. We have decided to include this change. However, the preprocessor guards need to be surrounded by /* *INDENT-OFF* */ / /* *INDENT-ON* */ in order to be accepted by the uncrustify tool we use PR code checks, and there are other header files in this repository that should be updated with this as well. To save you the trouble of updating this pull request, we have already included this in #56.

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants