Make "sys/queue.h" usable with C++
Eric van Gyzen
eric at vangyzen.net
Tue Jun 9 12:56:39 UTC 2015
On 06/09/2015 05:54, Hans Petter Selasky wrote:
> On 06/08/15 11:25, Poul-Henning Kamp wrote:
>> It's really a decision if we want to spread dependence on typeof()
>> to /usr/include isn't it ?
>
> Hi Paul-Henning,
>
> I'm aware about the typeof. Without typeof we would have to duplicate
> more of the queue macros, because in C++ you can make lists with both
> structs and classes. Else like some have suggested, we might drop the
> class/struct keyword, but that again will not work in external C
> sections in C++ files.
Did you test your claim in the last sentence? I did. Dropping the class/struct keyword in __cplusplus works fine under 'extern "C"'. If you _did_ test and it failed, please show your code to clarify any miscommunication.
Dropping the class/struct keyword has the advantage that it does not change the API. It has the disadvantage that types must be declared before they're used when #including <sys/queue.h> in C++ code. The latter is simply good form. There are three trivial declarations to fix in the src tree. An exprun would find those in ports and give a feel for the incidence rate in non-ports code. I would request this if anyone else is interested in this alternative.
https://reviews.freebsd.org/D2767
Eric
More information about the freebsd-hackers
mailing list