开发者

How can I compile code that uses getsubopt()?

I want to parse a list of options of the form key1开发者_如何学Python=val1, key2=val2, etc (like the options to mount -o). The getsubopt() function seems perfect for this task (http://www.gnu.org/s/hello/manual/libc/Suboptions.html). However, when I try to compile my code using gcc, I get:

warning: implicit declaration of function ‘getsubopt’

and the program segfaults when I run it.

I added #include <stdlib.h> but the compiler doesn't pick up the declaration.


Do you have:

#define _XOPEN_SOURCE 500
#include <stdlib.h>

at the top of the file that contains the call to getsubopt? The error you are getting is what you would expect if you call a function which has not been declared.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜