public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Question about gcc-3.3.3 and __attribute__ usage
@ 2004-03-06 15:57 Tom Williams
  2004-03-06 16:11 ` Ian Lance Taylor
  0 siblings, 1 reply; 5+ messages in thread
From: Tom Williams @ 2004-03-06 15:57 UTC (permalink / raw)
  To: gcc-help

Hi!  I'm running gcc-3.3.3 on a Slackware 8-based Linux system running 
the 2.6.3 Linux kernel and glibc-2.3.2.  I'm trying to build 
wine-20040213 and I'm having compile problems because the 
/usr/include/asm/byteorder.h header file uses an __attribute__ syntax 
which doesn't seem to be documented in the gcc manual:

#ifdef __GNUC__

/* For avoiding bswap on i386 */
#ifdef __KERNEL__
#include <linux/config.h>
#endif

static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x)
{
#ifdef CONFIG_X86_BSWAP

[snip]


Apparently, the Linux 2.6 kernel headers were changed to use 
__attribute_const__ syntax instead of __attribute__((const)):

http://www.ussg.iu.edu/hypermail/linux/kernel/0401.2/0935.html


This is causing others grief as they try to compile various apps:

http://www.ussg.iu.edu/hypermail/linux/kernel/0402.2/1989.html


My question is this:  will gcc be changed to support the 
__attribute_const__ (or similar kinds of) syntax or is the above 
described change incorrect syntax?

Here is the section of the manual discussing the 
__attribute__((attribute-list)) syntax:

http://gcc.gnu.org/onlinedocs/gcc-3.3.3/gcc/Attribute-Syntax.html#Attribute%20Syntax

Thanks in advance for your time.  :)

Peace...

Tom



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Question about gcc-3.3.3 and __attribute__ usage
  2004-03-06 15:57 Question about gcc-3.3.3 and __attribute__ usage Tom Williams
@ 2004-03-06 16:11 ` Ian Lance Taylor
  2004-03-06 17:27   ` Tom Williams
  0 siblings, 1 reply; 5+ messages in thread
From: Ian Lance Taylor @ 2004-03-06 16:11 UTC (permalink / raw)
  To: Tom Williams; +Cc: gcc-help

Tom Williams <tomdkat@comcast.net> writes:

> Apparently, the Linux 2.6 kernel headers were changed to use
> __attribute_const__ syntax instead of __attribute__((const)):

__attrbute_const__ is not valid gcc syntax.

However, it is a preprocessor macro defined by the Linux sources which
expands into valid gcc syntax.  I think the file is
include/linux/compiler.h, or some such.

Ian

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Question about gcc-3.3.3 and __attribute__ usage
  2004-03-06 16:11 ` Ian Lance Taylor
@ 2004-03-06 17:27   ` Tom Williams
  2004-03-06 17:57     ` Ian Lance Taylor
  0 siblings, 1 reply; 5+ messages in thread
From: Tom Williams @ 2004-03-06 17:27 UTC (permalink / raw)
  To: gcc-help

Ian Lance Taylor wrote:

>Tom Williams <tomdkat@comcast.net> writes:
>
>  
>
>>Apparently, the Linux 2.6 kernel headers were changed to use
>>__attribute_const__ syntax instead of __attribute__((const)):
>>    
>>
>
>__attrbute_const__ is not valid gcc syntax.
>
>However, it is a preprocessor macro defined by the Linux sources which
>expands into valid gcc syntax.  I think the file is
>include/linux/compiler.h, or some such.
>
>Ian
>
>  
>
Thanks!  :)

I found the following in /usr/include/linux/compiler.h:


#ifndef __attribute_const__
# define __attribute_const__    /* unimplemented */
#endif


Which I looks like it's trying to define __attribute_const__ to nothing 
so it will be automatically removed from this:

static __inline__ __attribute_const__ int foo()

resulting in:

static __inline__ int foo()

So, I wrote a test prog to see if this is actually the case:

tom@linux:~$ cat tom.c
#include <linux/compiler.h>

#ifdef __attribute_const__
#error It is defined!
#endif

static __inline__ __attribute_const__ int foo()
{
        return 0;
}

int main(int argc, char **argv)
{
        foo();

        return 0;
}
tom@linux:~$

and this is what happens when I compile it:

tom@linux:~$ make tom
cc     tom.c   -o tom
tom.c:7: error: syntax error before "int"
make: *** [tom] Error 1
tom@c71414-a:~$ gcc -E tom.c
# 1 "tom.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "tom.c"
# 1 "/usr/include/linux/compiler.h" 1 3 4
# 2 "tom.c" 2





static __inline__ __attribute_const__ int foo()
{
        return 0;
}

int main(int argc, char **argv)
{
        foo();

        return 0;
}
tom@linux:~$ cc --version
cc (GCC) 3.3.3
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

tom@linux:~$

Any idea on what might be up?  I guess the pre-processor isn't replacing 
the __attribute_const__ like it should???

Thanks...

Peace...

Tom





^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Question about gcc-3.3.3 and __attribute__ usage
  2004-03-06 17:27   ` Tom Williams
@ 2004-03-06 17:57     ` Ian Lance Taylor
  2004-03-06 18:17       ` Tom Williams
  0 siblings, 1 reply; 5+ messages in thread
From: Ian Lance Taylor @ 2004-03-06 17:57 UTC (permalink / raw)
  To: Tom Williams; +Cc: gcc-help

Tom Williams <tomdkat@comcast.net> writes:

> Any idea on what might be up?  I guess the pre-processor isn't
> replacing the __attribute_const__ like it should???

This is fairly unlikely.

I just took a look at linux/compiler.h in the linux 2.6.3
distribution.  That file only defines __attribute_const__ if
__KERNEL__ is defined.  You did not define the macro when compiling
your program.

Ian

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Question about gcc-3.3.3 and __attribute__ usage
  2004-03-06 17:57     ` Ian Lance Taylor
@ 2004-03-06 18:17       ` Tom Williams
  0 siblings, 0 replies; 5+ messages in thread
From: Tom Williams @ 2004-03-06 18:17 UTC (permalink / raw)
  To: gcc-help

Ian Lance Taylor wrote:

>Tom Williams <tomdkat@comcast.net> writes:
>
>  
>
>>Any idea on what might be up?  I guess the pre-processor isn't
>>replacing the __attribute_const__ like it should???
>>    
>>
>
>This is fairly unlikely.
>
>I just took a look at linux/compiler.h in the linux 2.6.3
>distribution.  That file only defines __attribute_const__ if
>__KERNEL__ is defined.  You did not define the macro when compiling
>your program.
>
>Ian
>
>  
>
Thanks.. I didn't look past the __attribute_const__ area in the header 
file. :)

Peace....

Tom

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-03-06 18:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-06 15:57 Question about gcc-3.3.3 and __attribute__ usage Tom Williams
2004-03-06 16:11 ` Ian Lance Taylor
2004-03-06 17:27   ` Tom Williams
2004-03-06 17:57     ` Ian Lance Taylor
2004-03-06 18:17       ` Tom Williams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).