getopt_long() problems

getopt_long() problems

Post by Gernot Kerschbaume » Wed, 16 Jun 1999 04:00:00


i'm using getopt_long() to parse the command line arguments and i'm
experiencing some weird behaviour:

first, i'm using the function strtol() within a case statement to
retrieve an option argument as a long int. when i'm using getopt_long,
then strtol() crashes the app, using getopt() works fine.

for a long option, i chose 'optional_argument', but when i give it an
argument, optarg is always null.

are these known problems or am i doing something wrong?

thanks for any help!

| vereinsgasse 32/12     | fax:      +43 1 2160493                     |
| a-1020 wien            | |


getopt_long() problems

Post by Kalle Olavi Niemital » Wed, 16 Jun 1999 04:00:00

> for a long option, i chose 'optional_argument', but when i give it an
> argument, optarg is always null.

How do you give it the argument?  It should be done like this:
$ program --option=argument
not like this:
$ program --option argument


1. GNU getopt_long problem

Dear all,

I am stuck by this: everytime I am using getopt_long to fetch command
line params in my application I get this error:

  Error on option --dummy=op: unknown option.
  Run 'src/application --help' to see a full list of available command line options.

The funny thing is, the program still starts as expected and receives
'op' as argument. So getopt_long does it's job, but before the program
can do some serious work, I get this confusing error...

I really don't see what causes this. And it only happens with
commands that expect parameters. If I did 'src/application --help' then
everything works just fine.

Any ideas?


2. sblive

3. Small problem with getopt_long()

4. W98-to-Linux Masquerade OK, but Linux-to-Linux Not!

5. getopt_long in AIX

6. Recommendations for SCSI 4X CD-ROM

7. Solaris 5.8: gcc - > getopt_long and ld: fatal error: ....

8. Adios Linux!

9. where is getopt_long() ?

10. getopt_long

11. getopt_long() on SunOS?

12. getopt_long: is this right?

13. getopt_long() examples