Hi C experts,
I have the following code for adding command line option for a program
int main (argc, argv)
int argc;
char *argv[];
{
char *mem_type; //memory type
char *name; //name of the memory
int addr; //address bits
int data; //data bits
int banks; //number of banks
int num_entries; //memory depth
int i; //internal variable
int cren; //cren variable for special cases
int y_add; //y-address bits for ldigram6tri
int x_add; //x-address bits for ldigram6tri
int sdata; //sdata bits for ldigram6tri
//Storing the memory models command line argument data into internal data variable.
for (i = 1; i < argc; i++)
{
if (!strcmp ((argv[i]) , "-type"))
mem_type = argv[i\+1];
/*
.other 2 options similar to above stncmp
.
*/
else if (argc < 9)
{
printf("\nWrong options and/or arguments used.\n");
printf("Please check Syntax and try again.\n\n");
print_message(argv[0]);
return 0;
}
}
//Selector for the memory type:
if \(!strcmp\(mem_type, "ra2_met"\)\) \{ gen\_samsung\_mem\_ra2_met\(name, num_entries, addr, data\);
\}
else if \(!strcmp \(mem_type, "ra2g_met"\)\) \{ gen\_samsung\_mem\_ra2_met\(name, num_entries, addr, data\);
\}
else \{ printf\("Invalid mem_type selected\\n"\);
printf\("Please check Syntax and try again.\\n\\n"\);
print_message\(argv[0]\);
return 10;
\}
return 0;
}
/*******sub***/
void print_message (argv_t1)
char argv_t1[];
{
printf\("Usage: %s <required/options : arguments>\\n\\n", argv_t1\);
printf\("required : arguments\\n\\n"\);
printf\(" -help : print out command line options.\\n\\n\\n"\);
}
but always get one error or another.
In function �main':
warning: passing argument 1 of �strcmp' makes pointer from integer without a cast
warning: passing argument 1 of �strcmp' makes pointer from integer without a cast
warning: passing argument 1 of �strcmp' makes pointer from integer without a cast
implicit declaration of function �print_message'
At top level:
warning: conflicting types for �print_message'
warning: previous implicit declaration of �print_message' was here
What would be the best way to compare the command line arguments so that I don't get the errors/warning?
Thank you very much for the help.