[Top][All Lists]

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

Re: error: redefinition of 'struct option'

From: Eric Blake
Subject: Re: error: redefinition of 'struct option'
Date: Wed, 17 Feb 2010 19:17:24 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20090812 Thunderbird/ Mnenhy/

According to Bruce Korb on 2/17/2010 7:03 PM:
> make[3]: Entering directory `/old-home/gnu/proj/sharutils-bld/lib'
> make[4]: Entering directory `/old-home/gnu/proj/sharutils-bld/lib'
> gcc -DHAVE_CONFIG_H -I. -I..     -g -Wall -MT close-hook.o -MD -MP -MF 
> .deps/close-hook.Tpo -c -o close-hook.o close-hook.c
> In file included from ./xstrtol.h:22,
>                  from ../config.h:1469,
>                  from close-hook.c:18:
> ./getopt.h:195: error: redefinition of 'struct option'

What platform is this on?  Is this a fresh bootstrap, with a modern git
checkout, or are you doing some incremental builds where you might have an
out-of-date getopt.h that needs to be regenerated?  Are you sure that
<config.h> is the first header included from withing close-hook.c?

> The *un*preprocessed gnulib-installed getopt.h has this:
>> #ifndef _GL_GETOPT_H
>> #if __GNUC__ >= 3
>> #pragma GCC system_header
>> #endif
>> /* The include_next requires a split double-inclusion guard.  We must
>>    also inform the replacement unistd.h to not recursively use
>>    <getopt.h>; our definitions will be present soon enough.  */
>> #if 1
>> # define _GL_SYSTEM_GETOPT
>> # include_next <getopt.h>
>> # undef _GL_SYSTEM_GETOPT
>> #endif
>> #ifndef _GL_GETOPT_H
> That looks wrong to me.  I guess the include_next will
> define _GL_GETOPT_H sometimes if _GL_SYSTEM_GETOPT is defined.

No, it is correct.  It is defining _GL_GETOPT_H so that the
gnulib-installed <unistd.h> won't try to do stupid things if the system
<getopt.h> tries to include <unistd.h>.

> OK.  Whatever.  The problem is that I'm getting "struct option"
> defined twice.  The second "#ifndef _GL_GETOPT_H" should be trained
> to cope with a valid getopt.h that doesn't understand _GL_SYSTEM_GETOPT.

The _only_ getopt.h that understands _GL_SYSTEM_GETOPT is gnulib's
getopt.h.  No one else should be defining or undefining that symbol, and
only gnulib's unistd.h should be checking if it is defined.

Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]