From: Richard Knutsson <ricknu-0@student.ltu.se>
To: kernel-janitors@vger.kernel.org
Subject: Re: [KJ] Any need for __cplusplus?
Date: Tue, 03 Apr 2007 22:50:52 +0000 [thread overview]
Message-ID: <4612DA4C.6030205@student.ltu.se> (raw)
In-Reply-To: <461201B3.8000800@student.ltu.se>
Hi and thank you all for your responses
Robert P. J. Day wrote:
> On Tue, 3 Apr 2007, Jaco Kroon wrote:
>
>
>> Richard Knutsson wrote:
>>
>>> Hello
>>>
>>> There were recently a thread in LKML about C++-usage in the kernel
>>> (again). That reminded me, why do we have those "ifdef
>>> __cplusplus"? As an example, we have this (in
>>> include/linux/stddef.h) when defining NULL as 0 in C++ and ((void
>>> *)0) otherwise. From what I can see, there is no reason to have
>>> them, or am I missing something? (like they are needed by
>>> libraries)
>>>
>> Many of these headers are exported to userspace, eg the
>> linux-headers package on many linux distributions. If a user
>> includes them from a C++ program, they shouldn't break.
>>
>
> the obvious question is this: is the kernel officially C++-free?
> that is, is the *only* reason one would see that C++ check is if
> something is being exported to userspace?
>
> if that's the case, the obvious approach is to generate the sanitized
> headers with "make headers_install" and see what C++ references are
> left:
>
> $ make distclean
> $ make headers_install
> $ cd usr/include
> $ grep -r cplusplus *
> linux/stddef.h:#if defined(__cplusplus)
> linux/socket.h:#elif defined(__cplusplus)
> $
>
> and that's it. if the kernel is truly C++-free, then there should be
> *no* C++ tests within the bounds of a "#ifdef __KERNEL__" test, isn't
> that right? but it's not that simple.
>
> consider, for example, the header file drivers/net/sk98lin/h/skgehw.h:
>
> ...
> #ifndef __INC_SKGEHW_H
> #define __INC_SKGEHW_H
>
> #ifdef __cplusplus
> extern "C" {
> #endif /* __cplusplus */
> ...
>
> note how that C++ test is not protected by a __KERNEL__ test but, on
> the other hand, it's not exported to userspace either. so what's the
> point of the C++ test if userspace never sees that header file? yes,
> it would seem that there are a lot of worthless C++ tests that could
> be removed if they never make it to userspace.
>
Yep, and just found a few C/C++ structs not even _used_ in the kernel...
Guess the __cplusplus may be worth a look or two since it seems to be
possible indicator of old cruft.
Thanks for reminding about "headers_install".
Richard Knutsson
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors
next prev parent reply other threads:[~2007-04-03 22:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-03 7:26 [KJ] Any need for __cplusplus? Richard Knutsson
2007-04-03 8:58 ` milindchoudhary
2007-04-03 9:30 ` Jaco Kroon
2007-04-03 10:40 ` Robert P. J. Day
2007-04-03 22:50 ` Richard Knutsson [this message]
2007-04-03 23:13 ` Robert P. J. Day
2007-04-03 23:22 ` Robert P. J. Day
2007-04-03 23:34 ` Howell, David P
2007-04-04 1:41 ` Richard Knutsson
2007-04-04 2:14 ` Randy Dunlap
2007-04-04 10:25 ` Robert P. J. Day
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4612DA4C.6030205@student.ltu.se \
--to=ricknu-0@student.ltu.se \
--cc=kernel-janitors@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.