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

Clean up use of 'extern "C"' in header files #504

Merged
merged 1 commit into from
May 19, 2023

Conversation

DimitriPapadopoulos
Copy link
Contributor

Private header files are only seen by the C compiler that builds the library. They don't need extern "C".

Public header files can be seen by a C++ compiler. They do need the extern "C". And it's best done individually in each public header file. On the other hand, header files that just use directives of the preprocessor need not extern "C".

Private header files are only seen by the C compiler that builds the
library. They don't need 'extern "C"'.

Public header files can be seen by a C++ compiler. They do need the
'extern "C"'. On the other hand, header files that just use directives
of the preprocessor need not 'extern "C"'.
@FrancescAlted
Copy link
Member

I'll say upfront that I am not a C++ guy. As far as I remember, this kind of protection was proposed by somebody many years ago to go into C-Blosc(1) code, and we adopted that convention (admittedly without any specific rule, because other headers are not protected this way).

Frankly, I don't know what to do here, but I'd appreciate if somebody else with C++ experience can chime in and reassure me by approving this PR.

@DimitriPapadopoulos
Copy link
Contributor Author

I can also add these to all header files. However, that's useless for private files, since these files are supposed to be compiled only by the C compiler that builds c-blosc2.

I am under the impression that the API of c-blosc2 is not well-delimited, and that you may have external code, or at least plugins, include private header files (#500 (comment)). In that case, it might make sent to protect private header files too, in case you include them from C++ code.

@FrancescAlted
Copy link
Member

Ok. I have been talking with a mate that is more familiar with C++, and what you are suggesting makes sense. It might be that C++ projects (e.g. dynamic plugins) may use private header files in C-Blosc2, but this can be addressed later (if needed).

Thanks!

@FrancescAlted FrancescAlted merged commit 0420bd4 into Blosc:main May 19, 2023
@DimitriPapadopoulos DimitriPapadopoulos deleted the __cplusplus branch May 20, 2023 14:08
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.

2 participants