[uClibc] getopt problem
Philip Rakity
prakity at yahoo.com
Sun Jan 2 14:52:18 UTC 2005
I am using gcc 3.4.3 and binutils binutils 2.15.94.0.2
but I have seen this problem with gcc 3.4.2. I am
cross compiling for armeb -- xscale -- big endian.
The following code snippet prints ---
argc = 2
argv[0]= ./wsm
argv[1]= -v7
./wsm: illegal option -- 7
but I thought that getopt should not return -. If
this code is compiled using crosstools -- it works.
regards,
Philip
main(int argc, char *argv[])
{
int i;
int c;
int nodaemon = 0;
int verbose = 0;
tNodeContext *nodeContext;
tRadioContext *radContext = NULL;
// Initialize aniAsfLogInit
aniAsfLogInit("WSM", LOG_ERR, 0); // No console Log
mainPid = getpid();
printf ("argc = %d\n", argc);
for (i = 0; i < argc; i++)
{
printf("argv[%d]= %s\n", i, argv[i]);
}
while ((c = getopt(argc, argv, "cdvh")) != EOF) {
switch(c) {
case 'c':
aniAsfLogConsole(1);
break;
case 'd':
nodaemon = 1;
break;
case 'v':
if (optind > 0 && optind < argc &&
argv[optind][0] != '-') {
verbose = atoi(argv[optind]);
aniAsfLogSetLevel(verbose);
}
break;
case 'h':
defaultargs();
break;
default:
aniAsfLogMsg(LOG_ERR, ANI_WHERE,
"Invalid Argument '%c'", c);
defaultargs();
break;
}
}
__________________________________
Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.
http://promotions.yahoo.com/new_mail
More information about the uClibc
mailing list