This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[plugin] compiling plugins with g++ and -pedantic gives getopt declaration error

Hi Everyone,

I have an Ubuntu 9.04 system that I've installed gcc-4.5.1 on, using an in-tree build of gmp, mpfr,  mpc, and libelf.

  luked@node:~$ gcc-4.5.1 -v
  Using built-in specs.
  Target: x86_64-unknown-linux-gnu
  Configured with: ../configure --prefix=/home/luked/local --enable-lto --enable-plugin --enable-multilib --program-suffix=-4.5.1
  Thread model: posix
  gcc version 4.5.1 (GCC) 

I'm evaluating the plugin interface for an academic project, but I have the following compilation problem. The test I am using is:

  luked@node:~$ cat test.cxx 
  extern "C" {
  #include "gcc-plugin.h"

This compiles fine without "-pedantic":

  luked@node:~$ g++-4.5.1 -I`g++-4.5.1 -print-file-name=plugin`/include -c test.cxx 

But adding "-pedantic" results in an error due to a function type mismatch for getopt.

  luked@node:~$ g++-4.5.1 -I`g++-4.5.1 -print-file-name=plugin`/include -pedantic -c test.cxx 
  In file included from /home/luked/local/lib/gcc/x86_64-unknown-linux-gnu/4.5.1/plugin/include/gcc-plugin.h:28:0,
                 from test.cxx:2:
  /home/luked/local/lib/gcc/x86_64-unknown-linux-gnu/4.5.1/plugin/include/system.h:382:53: error: declaration of ‘int getopt(int, char* const*, const char*)’ throws different exceptions
  /usr/include/getopt.h:152:12: error: from previous declaration ‘int getopt(int, char* const*, const char*) throw ()’

The plugin/include/system.h does indeed declare getopt without the throw().

  luked@:~$ sed -n 380,384p /home/luked/local/lib/gcc/x86_64-unknown-linux-gnu/4.5.1/plugin/include/system.h

  extern int getopt (int, char * const *, const char *);

And my auto-conf.h declares HAVE_DECL_GETOPT 0.

  luked@node:~$ sed -n 679,683p /home/luked/local/lib/gcc/x86_64-unknown-linux-gnu/4.5.1/plugin/include/auto-host.h
  /* Define to 1 if we found a declaration for 'getopt', otherwise define to 0.
  #define HAVE_DECL_GETOPT 0

I don't know what "USED_FOR_TARGET" means, but it isn't defined anywhere inside of the plugin.

  luked@node1x4x2a:~/local/lib/gcc/x86_64-unknown-linux-gnu/4.5.1/plugin$ grep -r USED_FOR_TARGET * | uniq
  include/config/i386/i386.h:#ifndef USED_FOR_TARGET
  include/auto-host.h:#ifndef USED_FOR_TARGET
  include/tm.h:#if defined IN_GCC && !defined GENERATOR_FILE && !defined USED_FOR_TARGET
  include/coretypes.h:#ifndef USED_FOR_TARGET

Does this seem like a configuration bug that I should report, or is it more likely that there's something wrong with my system?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]