-
Notifications
You must be signed in to change notification settings - Fork 100
chore: add cpp guards #41
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
Conversation
|
I think a more changes would be required to support C++ compilation. I am aware of the following C-only features being used that would need to be changed (either by switching to a C++-compatible approach or by using conditional compilation):
I'm not sure if @bvdberg would want to see the library modified to accommodate C++. However, here are some ways that we could do it: For 1), we could change the non-strict prototype to a union of strict prototypes, and remove the explicit suppression of For 2), we could simply remove the designated initializers from the braced initialization. However, 3) would most likely require conditional compilation. Here is one possible implementation using templates specialization to perform the desired override behavior: |
|
you are right, didn't test this enough with cpp... |
|
This framework is called ctest...and it's meant for unit testing in C. For C++ there are frameworks that are better suited for C++, like yaffut. These use C++ classes as the Fixture and tests become members of the fixture class. That works for C++, but not for C. So I'm not very interested in enabling C++ in ctest, since it just doesn't make sense. |
there are some projects that are going to transition from |
|
I agree with @gocarlos that there is real value in being able to reuse existing unit tests while migrating a project from C to C++. Another reason to consider adding C++ support is to enable projects using a combination of C and C++ to use a single unit testing framework. Currently, if those projects want to us a single framework, they have to make a choice between a C framework other than ctest (which most likely requires more boilerplate than ctest such as manual test registration) or a C++ framework (which prohibits testing of C code that makes use of C features not available in C++). IMO ctest is in a good position to provide the best of both worlds, filling this niche nicely. We only need the changes mentioned above to make it happen, so I think it is worth considering. |
|
I agree that for a certain scenario it could be useful. I do want to make sure a combined c/c++ testrunner does work. So certain cpp files would get a different 'view' of the ctest.h by your proposal. |
|
I have created this PR with the changes discussed above. |
|
Obsolete this pull #45 |
this simple change makes using this header with cpp code work out of the box