[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#335171: glibc-doc: getsubopt() has different interface with #define _GNU_SOURCE



Hello Daniel,

thanks for your prompt reply.

You are right concerning the missing prototype. But there is still a problem with the documentation. That's what I get:

Compiling example from " 25.3.13 Parsing of Suboptions Example" as is:
    ginster:/home/werner/csource# gcc -Wall -o testprg testprg.c
    testprg.c: In function `main':
    testprg.c:47: warning: implicit declaration of function `getsubopt'
Just as you told. No prototype.

Adding "#define _GNU_SOURCE" in the first line:
ginster:/home/werner/csource# gcc -Wall -o testprg testprg.c
    testprg.c: In function `main':
    testprg.c:48: warning: passing arg 2 of `getsubopt'
                           from incompatible pointer type
The declaration of parameter 2 does not match the declaration of getsubopt().

Removing "const" from the declaration of "mount_opts[]":
    ginster:/home/werner/csource# gcc -Wall -o testprg testprg.c
    ginster:/home/werner/csource#
No more warnings.

So my conclusion:
- The prototype is:
    int getsubopt (char **optionp, char* const *tokens, char **valuep);
  "const char* const *tokens" for the second argument seems to be an
  error in the documentation.
- In the example:
    "const char *mount_opts[] ="
  should be replaced by
    "char *mount_opts[] ="

Greetings
Werner



Reply to: