* PROBLEM: please remove reserved word "new" from kernel headers
@ 2005-07-06 9:26 Rob Prowel
2005-07-06 12:56 ` Jurriaan on adsl-gate
` (6 more replies)
0 siblings, 7 replies; 9+ messages in thread
From: Rob Prowel @ 2005-07-06 9:26 UTC (permalink / raw)
To: linux-kernel
[1.] One line summary of the problem:
2.4 and 2.6 kernel headers use c++ reserved word "new"
as identifier in function prototypes.
[2.] Full description of the problem/report:
When kernel headers are included in compilation of c++
programs the compile fails because some header files
use "new" in a way that is illegal for c++. This
shows up when compiling mySQL under linux 2.6. It
uses $KERNELSOURCE/include/asm-i386/system.h.
[3.] Keywords (i.e., modules, networking, kernel):
new, c++, kernel headers
[4.] Kernel version (from /proc/version):
2.4 and 2.6
While not an error, per se, it is kind of sloppy and
it is amazing that it hasn't shown up before now.
using the identifier "new" in kernel headers that are
visible to applications programs is a bad idea.
Thanks,
Rob Prowel
____________________________________________________
Sell on Yahoo! Auctions no fees. Bid on great items.
http://auctions.yahoo.com/
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: PROBLEM: please remove reserved word "new" from kernel headers 2005-07-06 9:26 PROBLEM: please remove reserved word "new" from kernel headers Rob Prowel @ 2005-07-06 12:56 ` Jurriaan on adsl-gate 2005-07-06 12:58 ` Jesper Juhl ` (5 subsequent siblings) 6 siblings, 0 replies; 9+ messages in thread From: Jurriaan on adsl-gate @ 2005-07-06 12:56 UTC (permalink / raw) To: Rob Prowel; +Cc: linux-kernel On Wed, Jul 06, 2005 at 02:26:57AM -0700, Rob Prowel wrote: > [1.] One line summary of the problem: > > 2.4 and 2.6 kernel headers use c++ reserved word "new" > as identifier in function prototypes. > This is a FAQ. 1) kernel headers are for kernel use. 2) the kernel is written in C, not C++. 3) if userspace needs those headers, write your own based on the kernel headers. Do you really think you're the first to notice this since it exists in 2.4 headers? Good luck, Jurriaan ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: PROBLEM: please remove reserved word "new" from kernel headers 2005-07-06 9:26 PROBLEM: please remove reserved word "new" from kernel headers Rob Prowel 2005-07-06 12:56 ` Jurriaan on adsl-gate @ 2005-07-06 12:58 ` Jesper Juhl 2005-07-06 13:06 ` Alexey Dobriyan ` (4 subsequent siblings) 6 siblings, 0 replies; 9+ messages in thread From: Jesper Juhl @ 2005-07-06 12:58 UTC (permalink / raw) To: Rob Prowel; +Cc: linux-kernel On 7/6/05, Rob Prowel <tempest766@yahoo.com> wrote: > [1.] One line summary of the problem: > > 2.4 and 2.6 kernel headers use c++ reserved word "new" > as identifier in function prototypes. > "new" is not a reserved word in C. the kernel is written in C. > [2.] Full description of the problem/report: > > When kernel headers are included in compilation of c++ > programs the compile fails because some header files > use "new" in a way that is illegal for c++. Userspace programs should not include kernel headers directly. But, if you really want it changed I suggest you create a patch and submit that for review/inclusion and see what feedback you get. -- Jesper Juhl <jesper.juhl@gmail.com> Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html Plain text mails only, please http://www.expita.com/nomime.html ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: PROBLEM: please remove reserved word "new" from kernel headers 2005-07-06 9:26 PROBLEM: please remove reserved word "new" from kernel headers Rob Prowel 2005-07-06 12:56 ` Jurriaan on adsl-gate 2005-07-06 12:58 ` Jesper Juhl @ 2005-07-06 13:06 ` Alexey Dobriyan 2005-07-06 18:08 ` Richard B. Johnson 2005-07-06 13:14 ` David Woodhouse ` (3 subsequent siblings) 6 siblings, 1 reply; 9+ messages in thread From: Alexey Dobriyan @ 2005-07-06 13:06 UTC (permalink / raw) To: Rob Prowel; +Cc: linux-kernel On Wednesday 06 July 2005 13:26, Rob Prowel wrote: > When kernel headers are included in compilation of c++ > programs the compile fails because some header files > use "new" in a way that is illegal for c++. This > shows up when compiling mySQL under linux 2.6. It > uses $KERNELSOURCE/include/asm-i386/system.h. Please read http://marc.theaimsgroup.com/?t=111637777000001&r=2&w=2 where people discuss this brokeness of MySQL. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: PROBLEM: please remove reserved word "new" from kernel headers 2005-07-06 13:06 ` Alexey Dobriyan @ 2005-07-06 18:08 ` Richard B. Johnson 0 siblings, 0 replies; 9+ messages in thread From: Richard B. Johnson @ 2005-07-06 18:08 UTC (permalink / raw) To: Alexey Dobriyan; +Cc: Rob Prowel, Linux kernel On Wed, 6 Jul 2005, Alexey Dobriyan wrote: > On Wednesday 06 July 2005 13:26, Rob Prowel wrote: >> When kernel headers are included in compilation of c++ >> programs the compile fails because some header files >> use "new" in a way that is illegal for c++. This >> shows up when compiling mySQL under linux 2.6. It >> uses $KERNELSOURCE/include/asm-i386/system.h. > > Please read http://marc.theaimsgroup.com/?t=111637777000001&r=2&w=2 > where people discuss this brokeness of MySQL. > Just for kicks, see if this 'fixes' it. Then contact the MySQL people and complain. --- /usr/src/linux-2.6.12/include/asm-i386/system.h.orig 2005-07-06 14:01:25.000000000 -0400 +++ /usr/src/linux-2.6.12/include/asm-i386/system.h 2005-07-06 14:03:42.000000000 -0400 @@ -235,7 +235,7 @@ /* * Atomic compare and exchange. Compare OLD with MEM, if identical, - * store NEW in MEM. Return the initial value in MEM. Success is + * store New in MEM. Return the initial value in MEM. Success is * indicated by comparing RETURN with OLD. */ @@ -244,26 +244,26 @@ #endif static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, - unsigned long new, int size) + unsigned long New, int size) { unsigned long prev; switch (size) { case 1: __asm__ __volatile__(LOCK_PREFIX "cmpxchgb %b1,%2" : "=a"(prev) - : "q"(new), "m"(*__xg(ptr)), "0"(old) + : "q"(New), "m"(*__xg(ptr)), "0"(old) : "memory"); return prev; case 2: __asm__ __volatile__(LOCK_PREFIX "cmpxchgw %w1,%2" : "=a"(prev) - : "q"(new), "m"(*__xg(ptr)), "0"(old) + : "q"(New), "m"(*__xg(ptr)), "0"(old) : "memory"); return prev; case 4: __asm__ __volatile__(LOCK_PREFIX "cmpxchgl %1,%2" : "=a"(prev) - : "q"(new), "m"(*__xg(ptr)), "0"(old) + : "q"(New), "m"(*__xg(ptr)), "0"(old) : "memory"); return prev; } Cheers, Dick Johnson Penguin : Linux version 2.6.12 on an i686 machine (5537.79 BogoMips). Notice : All mail here is now cached for review by Dictator Bush. 98.36% of all statistics are fiction. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: PROBLEM: please remove reserved word "new" from kernel headers 2005-07-06 9:26 PROBLEM: please remove reserved word "new" from kernel headers Rob Prowel ` (2 preceding siblings ...) 2005-07-06 13:06 ` Alexey Dobriyan @ 2005-07-06 13:14 ` David Woodhouse 2005-07-06 14:05 ` Jakob Oestergaard ` (2 subsequent siblings) 6 siblings, 0 replies; 9+ messages in thread From: David Woodhouse @ 2005-07-06 13:14 UTC (permalink / raw) To: Rob Prowel; +Cc: linux-kernel On Wed, 2005-07-06 at 02:26 -0700, Rob Prowel wrote: > While not an error, per se, it is kind of sloppy and > it is amazing that it hasn't shown up before now. > using the identifier "new" in kernel headers that are > visible to applications programs is a bad idea. It _is_ an error, on mysql's part. The kernel headers are _not_ intended to be visible to applications, in the general case. Why is mysql including this header? -- dwmw2 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: PROBLEM: please remove reserved word "new" from kernel headers 2005-07-06 9:26 PROBLEM: please remove reserved word "new" from kernel headers Rob Prowel ` (3 preceding siblings ...) 2005-07-06 13:14 ` David Woodhouse @ 2005-07-06 14:05 ` Jakob Oestergaard 2005-07-06 14:43 ` Michal Schmidt 2005-07-06 15:35 ` Schneelocke 6 siblings, 0 replies; 9+ messages in thread From: Jakob Oestergaard @ 2005-07-06 14:05 UTC (permalink / raw) To: Rob Prowel; +Cc: linux-kernel On Wed, Jul 06, 2005 at 02:26:57AM -0700, Rob Prowel wrote: > [1.] One line summary of the problem: > > 2.4 and 2.6 kernel headers use c++ reserved word "new" > as identifier in function prototypes. Correction: [1.] One line summary of problem: Userspace application is making use of private kernel headers. > > [2.] Full description of the problem/report: > > When kernel headers are included in compilation of c++ > programs the compile fails because some header files > use "new" in a way that is illegal for c++. This > shows up when compiling mySQL under linux 2.6. It > uses $KERNELSOURCE/include/asm-i386/system.h. Corrected: [2.] Full description of the problem/report: When userspace applications include headers they shouldn't, all kinds of problems can appear. One example of this shows up when compiling mySQL under linux 2.6. It uses $KERNELSOURCE/include/asm-i386/system.h. ... > While not an error, per se, it is kind of sloppy and > it is amazing that it hasn't shown up before now. It has shown up, and it has been discussed. Search the archives. I'm pretty sure the exact problem you're reporting was discussed here a few months back. > using the identifier "new" in kernel headers that are > visible to applications programs is a bad idea. Noone's doing that. Because the headers aren't meant to be visible. This is not a C vs. C++ problem and it has nothing to do with 'sloppiness'. Something much subtler could have happened had it been C application code which would have parsed cleanly but just broken in strange ways (due to assumptions in kernel header code which just happen to not be met in the userspace code). Actually, you should be greatful someone used 'new' - at least now the error is caught at compile time ;) It should be simple to fix MySQL to keep it's dirty little fingers off of the kernel's private parts.. Really, that is the solution. Take a look at *what* MySQL is doing with the header. If it is the same problem (I have not double checked, but I guess chances are good) as was reported earlier, it's really just a small braindamage in MySQL which is easily fixed (thus removing the need for inclusion of the header in question). -- / jakob ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: PROBLEM: please remove reserved word "new" from kernel headers 2005-07-06 9:26 PROBLEM: please remove reserved word "new" from kernel headers Rob Prowel ` (4 preceding siblings ...) 2005-07-06 14:05 ` Jakob Oestergaard @ 2005-07-06 14:43 ` Michal Schmidt 2005-07-06 15:35 ` Schneelocke 6 siblings, 0 replies; 9+ messages in thread From: Michal Schmidt @ 2005-07-06 14:43 UTC (permalink / raw) To: Rob Prowel; +Cc: linux-kernel Rob Prowel wrote: > [1.] One line summary of the problem: > > 2.4 and 2.6 kernel headers use c++ reserved word "new" > as identifier in function prototypes. Yes, the kernel is written in C, not C++. > using the identifier "new" in kernel headers that are > visible to applications programs is a bad idea. Programs are not supposed to include kernel headers. This is a FAQ, see the archives. Michal ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: PROBLEM: please remove reserved word "new" from kernel headers 2005-07-06 9:26 PROBLEM: please remove reserved word "new" from kernel headers Rob Prowel ` (5 preceding siblings ...) 2005-07-06 14:43 ` Michal Schmidt @ 2005-07-06 15:35 ` Schneelocke 6 siblings, 0 replies; 9+ messages in thread From: Schneelocke @ 2005-07-06 15:35 UTC (permalink / raw) To: Rob Prowel; +Cc: linux-kernel On 06/07/05, Rob Prowel <tempest766@yahoo.com> wrote: > 2.4 and 2.6 kernel headers use c++ reserved word "new" > as identifier in function prototypes. > [...] > While not an error, per se, it is kind of sloppy and > it is amazing that it hasn't shown up before now. > using the identifier "new" in kernel headers that are > visible to applications programs is a bad idea. This has been discussed before: see http://marc.theaimsgroup.com/?l=linux-kernel&m=111637766131104&w=2 and the ensuing thread. -- schnee ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2005-07-07 0:23 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2005-07-06 9:26 PROBLEM: please remove reserved word "new" from kernel headers Rob Prowel 2005-07-06 12:56 ` Jurriaan on adsl-gate 2005-07-06 12:58 ` Jesper Juhl 2005-07-06 13:06 ` Alexey Dobriyan 2005-07-06 18:08 ` Richard B. Johnson 2005-07-06 13:14 ` David Woodhouse 2005-07-06 14:05 ` Jakob Oestergaard 2005-07-06 14:43 ` Michal Schmidt 2005-07-06 15:35 ` Schneelocke
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox