Re: gcc alternate keywords and kernel source

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Apr 10, 2007 at 06:45:32AM -0400, Robert P. J. Day wrote:
> 
>   from the gcc manual
> (http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Alternate-Keywords.html#Alternate-Keywords):
> 
> "-ansi and the various -std options disable certain keywords. This
> causes trouble when you want to use GNU C extensions, or a
> general-purpose header file that should be usable by all programs,
> including ISO C programs. The keywords asm, typeof and inline are not
> available in programs compiled with -ansi or -std (although inline can
> be used in a program compiled with -std=c99). The ISO C99 keyword
> restrict is only available when -std=gnu99 (which will eventually be
> the default) or -std=c99 (or the equivalent -std=iso9899:1999) is
> used."
> 
> "The way to solve these problems is to put `__' at the beginning and
> end of each problematical keyword. For example, use __asm__ instead of
> asm, and __inline__ instead of inline. "
> 
>   what this tells me (and CMIIW) is that one need only use the "__"
> variations in kernel source that is being exported to userspace, yes?
> that is, in the same way that using "__u32" instead of just "u32" is
> only *necessary* under the same circumstances.

For userspace, the problem is not restricted to keywords.

Userspace that indirectly #include's kernel headers might already use 
the same name for something completely different.

>   so while it's not, technically speaking, *wrong*, it's not necessary
> to have used that longer variation in, say, net/packet/af_packet.c:
> 
> #define XC(a, b) ({ __typeof__ ((a)) __t; __t = (a); (a) = (b); __t;
> })
> 
> since that's a source file and there's no way that would have made it
> to userspace anyway.  do i understand that correctly?

#define's are a different but related problem:

"t" is a valid variable name, and there could be a variable "t" in
kernel code using XC().

> rday

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux