getopt and X programs?

getopt and X programs?

Post by F. Heitka » Tue, 03 Aug 1999 04:00:00

I'm using getopt in an X program.  I've noticed there is
a bit of a conflict with with some X calls (can't remember
the call name at the moment ...XtAppInitialize()?)  Anyway
the X call parses the command line for the X related options.
How do I get program specific options in there in a friendly

The ugly way I do it now:

int main( int argc, char *argv[] )
        ... code


        ... code

        /* use GUI if user wants */
        gui( argc, argv );

        ... code



in gui( int argc, char *argv[] )
        XtAppInitialize( blah, blah ...)



1. portable getopt program

I'm moving a program from Linux to Solaris, and the following problem
* getopt functions is in stdlib.h on solaris, but getopt.h on linux.
* a global variable long_options used for some optimization purpose for
   gives me compilation problems:
       todo.c:354: warning: excess elements in struct initializer
       todo.c:354: warning: (near initialization for `long_options[7]')

So, how do I do getopt handling portable. And can it be done for both
--option and -o arguments.
I suspect that I'm not the first to find this problem.


2. glibc download

3. Matrox Mystique ands X.

4. Apache/LDAP

5. RCS and getopt

6. int, pid_t, size_t and ssize_t

7. getopt and list of args

8. Korganizer Exchange 2000 plugin

9. getopt in csh

10. anyone know if there's a getopt lib for solaris ?

11. getopt C function

12. getopt - how to check number of flag

13. getopt rearranges argv, optind doesn't care