Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Compilation problems??
Programming <sysdev_at_mb.sympatico.ca> wrote in article
<33EF2BCD.697A_at_mb.sympatico.ca>...
> I hope that someone can tell me what
> the compiliation errors are.
> Are they compilation problems??
> Or something else?
[snip to start of code sample]
> #include "stdio.h"
>
> int main()
> {
>
> char *ls_returnvalue;
>
> ls_returnvalue = "";
> ls_returnvalue = checkvalue (); /* line 86 */
> printf("ls_returnvalue is: %s\n", ls_returnvalue);
>
> exit(0);
> } /********** end main ************/
>
>
>
>
> char *checkvalue() /*line 96 */
> {
>
> char *ls_getvalue;
> int li_valid;
>
> ls_getvalue = (char*) malloc(80);
> scanf("%s\n", ls_getvalue);
>
> li_valid = 0;
>
> if (li_valid == 0)
> {
> printf("ls_getvalue is: %s\n", ls_getvalue);
> free (ls_getvalue);
> ls_getvalue = 0;
> } /* end if */
>
>
> } /************ end checkvalue ****************/
>
>
>
> "char1.c", line 86.21: 1506-068 (S) Operation between types
"char*" and "int" is not
> allowed.
> "char1.c", line 96.7: 1506-343 (S) Redeclaration of checkvalue
differs from previous
> declaration on line 86 of "char1.c".
> "char1.c", line 96.7: 1506-050 (I) Return type "char*" in
redeclaration is not
> compatible with the previous return type "int".
> make: 1254-004 The error code from the last command is 1.
>
> Stop.
>
>
> ((
> The same errors also occur if I copy everything to char2.c,
and compile with:
> cc char2.c
>
> "char2.c", line 9.21: 1506-068 (W) Operation between types
"unsigned char*" and "int" is
> not allowed.
> "char2.c", line 19.7: 1506-343 (S) Redeclaration of checkvalue
differs from previous
> declaration on line 9 of "char2.c".
> "char2.c", line 19.7: 1506-050 (I) Return type "unsigned
char*" in redeclaration is not
> compatible with the previous return type "i.
> ))
>
>
>
> Any ideas??
>
>
> Thanks in advance,
>
> Rodger
>
add prototype:
char *checkvalue(void);
BEFORE main. When the compiler sees the call to checkvalue in
main, it has not yet seen the definition of checkvalue, which
comes later. Therefore it must make the default assumption that
checkvalue is a function which returns int, the default for all
functions called without prototypes. When the compiler does see
your actual checkvalue code, it sees a second definition for
checkvalue with a different return type, this causes the error.
-- Jack Klein All views expressed in this message are mine, and not necessarily that of my company or any of our clients. Remove nospam from address to reply.Received on Tue Aug 12 1997 - 00:00:00 CDT
![]() |
![]() |