Hello linuxquestions,
I am using the function "getopt_long_only" in getopt.h to parse the command line options of my C++ program. The program compiles and runs fine on windows 7 with mingw and g++. But when I compile it with g++ on my Debian system (latest stable release) I get these errors:
Code:
/usr/include/getopt.h: In function ‘int getopt(int, char* const*, const char*)’:
/usr/include/getopt.h:153: error: expected primary-expression before ‘,’ token
/usr/include/getopt.h: In function ‘int getopt_long(int, char* const*, const char*, const option*, int*)’:
/usr/include/getopt.h:162: error: expected primary-expression before ‘,’ token
/usr/include/getopt.h: In function ‘int getopt_long_only(int, char* const*, const char*, const option*, int*)’:
/usr/include/getopt.h:166: error: expected primary-expression before ‘,’ token
I couldn't find anyone with a similar problem by searching on google and since I am not that great at C/C++ programming at the moment, I am not sure whats wrong (if anything) with getopt.h.
Any help or direction to documentation and information is appreciated!
Thanks,
Inhumed
Edit: Not sure If I need to add the getopt.h code to this post, I have not edited it ever and I have the newest version of glib that the debian main server offers, But here is the problematic part of getopt.h:
It seems to not like the THROW lines
Code:
#ifdef __GNU_LIBRARY__
/* Many other libraries have conflicting prototypes for getopt, with
differences in the consts, in stdlib.h. To avoid compilation
errors, only prototype getopt for the GNU C library. */
extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
__THROW;
#else /* not __GNU_LIBRARY__ */
extern int getopt ();
#endif /* __GNU_LIBRARY__ */
#ifndef __need_getopt
extern int getopt_long (int ___argc, char *const *___argv,
const char *__shortopts,
const struct option *__longopts, int *__longind)
__THROW;
extern int getopt_long_only (int ___argc, char *const *___argv,
const char *__shortopts,
const struct option *__longopts, int *__longind)
__THROW;
#endif