cvra / platform-abstraction

Platform abstraction layer for microcontrollers
3 stars 6 forks source link

add extern "C" to headers for C++ #45

Closed Stapelzeiger closed 10 years ago

antoinealb commented 10 years ago

I don't know what are the "good practices" on that. So far I have been doing it in the cpp file : https://github.com/cvra/platform-abstraction/blob/8a687dd3881ee2fccf8f5ea0ffbfb01b34c634eb/tests/criticalsection_mock_test.cpp#L6-8

antoinealb commented 10 years ago

If we decide that this is the way we want to do extern "C", this should go into the coding style. What does the rest of the team think ?

pierluca commented 10 years ago

I would say it depends on what we expect the final project to look like.

If the code base is going to be pretty much mixed C/C++, then extern "C" in all the headers is the way to go. In principle, this is the solution I would favor (and thus the pull request is okay by me)

However, if only a minority of files are going to be C++, then we might assume that those are the only ones that would need to specify extern "C" on includes and Antoine's solution could be okay.

antoinealb commented 10 years ago

Well there will probably be two kind of C++ files :

  1. Unit tests
  2. All files implementing some sort of CAN functionality because UAVCAN is written in C++
Stapelzeiger commented 10 years ago

And maybe C++ could also be an option for our own codebase. (only a very restricted subset with strong usage guidelines of course) I'm for putting the extern C declaration in the headers.

antoinealb commented 10 years ago

Then should we put it in all headers ?

Stapelzeiger commented 10 years ago

Yes

antoinealb commented 10 years ago

Okie, I will put this in the coding style then.