I'm using argp and when I finally try to compile my C++ prog I get:
/usr/include/argp.h: In function `void argp_usage(const argp_state*)':
/usr/include/argp.h:565: error: declaration of `void argp_usage(const
argp_state*) throw ()' throws different exceptions
/usr/include/argp.h:502: error: than previous declaration `void
argp_usage(const argp_state*)'
I'm using g++ 3.3.4, glibc 2.3.5 and compiling with -Wall -std=c++98.
Any ideas why this is happening? Using extern "C" { #include <argp.h> }
won't help. :(
Cheers,
Paulo Matos
> The error says that the two declarations are not the same.
>
> The declaration
>
> void argp_usage(const argp_state*);
>
> is essentially a short form of
>
> void argp_usage(const argp_state*) throw(...);
>
> which is not the same as
>
> void argp_usage(const argp_state*) throw ();
>
> There must be something wrong with the header file or more likely with
> preprocessor definitions.
Indeed this is a strange issue. I can work out simple examples with
argp but in my program just blows. While trying to compile a bison
generated parser which indirectly includes argp with the following
flags (most added automaticly by autoconf/automake, do I need to have
anything for argp in configure.ac?):
g++ -DHAVE_CONFIG_H -I. -I. -I.. -ansi -std=c++98 -pedantic -Wall
-ggdb -I./include "-DBUILDDATE=\"`date +'%Y-%b-%d %R'`\"" -DESATLOG=5
-g -O2 -MT msat-parser.o -MD -MP -MF ".deps/msat-parser.Tpo" -c -o
msat-parser.pre msat-parser.cc
if I change -c to -E and check the preprocessed file I get the
following line where the warning shows up:
502: extern void argp_usage (const struct argp_state *__state);
503: extern void __argp_usage (const struct argp_state *__state);
...
# 563 "/usr/include/argp.h" 3 4
extern __inline__ void
argp_usage (const struct argp_state *__state) throw ()
{
argp_state_help (__state, stderr, (0x02 | 0x04 | 0x100));
}
Can it be because of inline? Is there any known issue on argp with
flex/bison or autoconf/automake specifics for argp?
Cheers,
Paulo Matos
Found the problem. The -O2 in conjuction with -pedantic generates the
error. Seems I'll drop -pedantic. :)
Cheers,
Paulo Matos
Paulo Matos escreveu:
> Found the problem. The -O2 in conjuction with -pedantic generates the
> error. Seems I'll drop -pedantic. :)
You may report a bug against argp, since the header is inconsistent.
Submitted:
bug 2263.
http://sources.redhat.com/bugzilla/show_bug.cgi?id=2263