Page MenuHomeFreeBSD

ctld: Convert to C++
AcceptedPublic

Authored by jhb on Wed, Feb 26, 3:54 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Mar 17, 8:12 AM
Unknown Object (File)
Fri, Mar 14, 5:47 AM
Unknown Object (File)
Mon, Mar 3, 2:39 PM
Unknown Object (File)
Mon, Mar 3, 1:24 PM
Unknown Object (File)
Mon, Mar 3, 5:27 AM
Unknown Object (File)
Fri, Feb 28, 11:40 PM
Unknown Object (File)
Fri, Feb 28, 4:45 PM
Unknown Object (File)
Fri, Feb 28, 11:40 AM
Subscribers

Details

Reviewers
asomers
Summary

This is the minimal set of changes need to compile as C++ so git can
handle the rename correctly.

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

jhb requested review of this revision.Wed, Feb 26, 3:54 PM

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!

This revision is now accepted and ready to land.Tue, Mar 18, 6:22 PM