Disable K&R getopt() prototype

Create issue
Issue #1089 closed
Erik Schnetter created an issue

The file getopt.h, taken from glibc, defines a prototype for the function getopt() (which is not actually used in Cactus). Depending on the compiler used, this is either an ANSI prototype with arguments, or a K&R prototype without arguments.

The IBM C++ compiler does not handle the K&R prototype well; it complains that it sees ANSI prototypes in stdio.h and stdlib.h, and aborts.

Since we don't call getopt() in Cactus, I suggest to disable the K&R prototype:

Index: gnu/getopt.h
--- gnu/getopt.h    (revision 4867)
+++ gnu/getopt.h    (working copy)
@@ -150,7 +150,9 @@
                 int __long_only);
 # endif
 #else /* not __STDC__ */
-extern int getopt ();
+/* The declaration below leads to a prototype mismatch with
+   IBM XL C/C++ for AIX, V11.1 (5724-X13), Version: 11.01.0000.0005 */
+/* extern int getopt (); */
 # ifndef __need_getopt
 extern int getopt_long ();
 extern int getopt_long_only ();

I also tried various options to disable the ANSI prototypes in the system libraries (didn't help), and tried updating getopt.h to a more recent version (didn't help either).


Comments (6)

  1. Frank Löffler
    • removed comment

    I don't see a problem removing it, as I also didn't find code in Cactus using it. However, would it be also possible to remove all getopt-related calls/files? (src/gnu/getopt*)

  2. Erik Schnetter reporter
    • removed comment

    No; if the system does not provide getopt_long_only, Cactus would not build.

  3. Log in to comment