Owen_Townsend
4th September 2008, 02:12
/* testarray.c - to test compile warnings/errors */
/* "warning: passing arg1 from incompatible type" */
/* - by Owen Townsend, UV Software, Aug 25/2008 */
/* - original program was 20,000 lines (uvcopy.c) */
/* so I wrote this small test program to experiment*/
/* I was trying to pass a char ptr to a function which expects an array ptr*/
/* I was getting warning "passing arg1 from incompatible pointer type" */
/* note - program works OK, but I would like to eliminate the warning msg */
/* - I tried cast (char[][100]) but get "error: cast specifies array type" */
/* This test program written to investigate problem */
/* - here are warnings/errors from this test program */
/* 34: warning: passing arg1 of 'wordsep1' from incompatible pointer type*/
/* 36: error: cast specifies array type */
/* 38: error: cast specifies array type */
/* 40: warning: passing arg1 of 'wordsep1' from incompatible pointer type*/
char line[1000]; /* string to be split into words array */
char words[9][100]; /* words isolated from line */
char words2[1000]; /* words declared as an area vs array */
char *(words2p[9][100]); /* ptr to array of 100 elements */
/* declare prototype for wordsep1() function */
int wordsep1(char words[][100], char *input, int max, short bits);
int main (int argc, char *argv[])
{
wordsep1(words,line,9,0x03); /*32 <-- OK (no warning or error) */
wordsep1(words2,line,9,0x03); /*34 warning: arg1 incompatible type */
wordsep1((char[][100])words2,line,9,0x03); /*36 error: cast array type */
words2p = (char[][100])&(words2[0][0]); /*38 error: cast array type */
wordsep1(words2p,line,9,0x03); /*40 warning: arg1 incompatible type */
return(0);
}
/*-------------------------- wordsep1 ----------------------------*/
/* separate input string into array of words */
int wordsep1(char words[][100], char *input, int max, short bits)
{
return(1);
}
/* "warning: passing arg1 from incompatible type" */
/* - by Owen Townsend, UV Software, Aug 25/2008 */
/* - original program was 20,000 lines (uvcopy.c) */
/* so I wrote this small test program to experiment*/
/* I was trying to pass a char ptr to a function which expects an array ptr*/
/* I was getting warning "passing arg1 from incompatible pointer type" */
/* note - program works OK, but I would like to eliminate the warning msg */
/* - I tried cast (char[][100]) but get "error: cast specifies array type" */
/* This test program written to investigate problem */
/* - here are warnings/errors from this test program */
/* 34: warning: passing arg1 of 'wordsep1' from incompatible pointer type*/
/* 36: error: cast specifies array type */
/* 38: error: cast specifies array type */
/* 40: warning: passing arg1 of 'wordsep1' from incompatible pointer type*/
char line[1000]; /* string to be split into words array */
char words[9][100]; /* words isolated from line */
char words2[1000]; /* words declared as an area vs array */
char *(words2p[9][100]); /* ptr to array of 100 elements */
/* declare prototype for wordsep1() function */
int wordsep1(char words[][100], char *input, int max, short bits);
int main (int argc, char *argv[])
{
wordsep1(words,line,9,0x03); /*32 <-- OK (no warning or error) */
wordsep1(words2,line,9,0x03); /*34 warning: arg1 incompatible type */
wordsep1((char[][100])words2,line,9,0x03); /*36 error: cast array type */
words2p = (char[][100])&(words2[0][0]); /*38 error: cast array type */
wordsep1(words2p,line,9,0x03); /*40 warning: arg1 incompatible type */
return(0);
}
/*-------------------------- wordsep1 ----------------------------*/
/* separate input string into array of words */
int wordsep1(char words[][100], char *input, int max, short bits)
{
return(1);
}