Skip to content

Differences to C's getopt() & getopt_long()

Hani Andreas Ibrahim edited this page Apr 2, 2022 · 1 revision

Differences oft f90getoptto the C-functions getopt() and getopt_long().

From C version

  • when options are finished, C version returns -1 instead of char(0), and thus stupidly requires an int instead of a char.
  • does not support optreset
  • does not support "--" as last argument
  • if no argument, optarg is blank, not NULL
  • argc and argv are implicit

For long options

  • optional argument to getopt(), rather than separate function getopt_long()
  • has_arg is logical, and does not support optional_argument
  • does not support flag field (and thus always returns val)
  • does not support longindex
  • knows the length of longopts, so does not need an empty last record