Re: gcc-warning: more info
Daniel Reuter <reuter@Uni-Hohenheim.DE> writes:
DR> Thanks to all, who responded up to now. I think I'll give some more
DR> information, as I still don't understand, why the warning
DR> main.c:158: assignment makes pointer from integer without a cast
DR> is generated in my case:
DR>
DR> I have the following (among some other function and structure
DR> declarations) in my program-header-file 'bet.h':
DR>
DR> #include <stdlib.h>
DR> #include <stdio.h>
DR>
DR> struct provided_data{
DR> };
DR>
DR> struct provided_data *read_data(char *);
DR>
DR>
DR> This function is in file 'scanner.c' and does the following:
DR>
DR> #include "bet.h"
DR>
DR> struct provided_data *read_data(char *input_file_name)
DR> {
DR> }
DR>
DR>
DR> In file main.c I have the following:
DR>
DR> #include "bet.h"
DR>
DR> int main(int argc, char **argv)
DR> {
DR> struct provided_data *input_data;
DR>
DR> ---> input_data=read_data(input_file_name);
DR> }
Do you include a prototype for read_data() in main.c? This would
probably be done by creating 'scanner.h', and putting a prototype
struct provided_data *read_data(char *input_file_name);
in there. If there's no prototype, then the C compiler will, for
historical reasons, assume that the function is actually
int read_data(...);
and so you're then trying to assign the result of read_data
(implicitly an int) to input_data (a pointer).
--
David Maze dmaze@mit.edu http://www.mit.edu/~dmaze/
"Theoretical politics is interesting. Politicking should be illegal."
-- Abra Mitchell
Reply to: