This is the minimal set of changes need to compile as C++ so git can
handle the rename correctly.
Details
- Reviewers
asomers
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Skipped - Unit
Tests Skipped - Build Status
Buildable 62637 Build 59521: arc lint + arc unit
Event Timeline
A few functions, like conf_set_debug, will now be extern "C" in the header file, but not in their implementation. It might work, but I don't think it's right. Also, conf.c seems to have two purposes. It defines C functions used by parse.y, and it also defines C functions used by ctld.cc. Maybe we should leave conf.c as a C file, but move some its ctld functions into ctld.cc itself? OTOH, if you're going for "minimal set of changes necessary to build as C++, it would be easier just to move those prototypes out of the "extern C" section.
Hmm, my assumption is that the extern "C" for the prototype is sufficient for the compiler to use the "C" symbol for the function when compiling conf.cc, but that permits using C++ constructs in conf.cc. In the future these methods in conf.cc will be invoking methods on C++ objects so it needs to be a conf.cc file, just that the symbols exported from it use C symbol names (not mangled).
Hmm, cppreference.com has an explicit example of this case that it says is fine:
https://en.cppreference.com/w/cpp/language/language_linkage
In particular:
A redeclaration of an entity without a linkage specification inherits the language linkage of the entity and its type (if exists).
Followed by this example:
extern "C" int g(); int g(); // OK, has C language linkage
A redeclaration of an entity without a linkage specification inherits the language linkage of the entity and its type (if exists).
Ahh, good find!