Re: bug or problem with gcc and include files

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

 



On Thu, Mar 25, 2004 at 10:49:54AM +0100, David Jansen wrote:
> I have to install a program here at work that compiles fine on SuSe and
> on RedHat 9, but not on FC1.
> After experimenting with the routines and eliminating everything that is
> not necessary to reproduce the bug, this is what it boils down to:
> $ cat test1.c
> void test1()
> {
> #include <sys/file.h>
>  
> return(0);
> }
> $ gcc -o test1.o -c test1.c
> In file included from /usr/include/sys/types.h:219,
>                  from /usr/include/bits/fcntl.h:25,
>                  from /usr/include/fcntl.h:33,
>                  from /usr/include/sys/file.h:25,
>                  from test1.c:3:
> /usr/include/sys/sysmacros.h: In function `test1':
> /usr/include/sys/sysmacros.h:43: error: nested function `gnu_dev_major' declared `extern'
> /usr/include/sys/sysmacros.h:49: error: nested function `gnu_dev_minor' declared `extern'
> /usr/include/sys/sysmacros.h:55: error: nested function `gnu_dev_makedev' declared `extern'
> 
> Now that's easy to fix; if I move the #include out of the function to
> the top of the source file, it compiles woithout any problems. Only the
> package author didn't accept this "patch", stating that the program is
> correct and the bug is in the fedora includes or gcc version.
> What is your collective wisdom on this subject?

The package author is wrong.  IEEE Std 1003.1-2001 XSH 2.2.2 says
(see
http://www.opengroup.org/onlinepubs/007904975/functions/xsh_chap02_02.html#tag_02_02_02
) says:
"If used, the application shall ensure that a header is included outside
of any external declaration or definition, " ...

Although #include <sys/file.h> is not a POSIX standard header and is not
governed by this standard, it includes <fcntl.h> which is a POSIX header.
The testcase above includes (indirectly) a standard header inside of a
function definition and thus violates the POSIX requirements.

	Jakub



[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux