Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
December 28, 2002 Its been a while! | ||||
---|---|---|---|---|
| ||||
Just getting back into programming, stumped on this error message from some old code I wrote. Function is determing size of memory to allocate. struct runners * runner_alloc(struct runners *runmem_ptr, long *runsize_ptr, FILE *runner_fp) { long file_size; if( (fseek(runner_fp,(long) 0 ,SEEK_END)) != NULL) ****** ERROR LINE ****** { move_error("runners file"); } file_size = ftell(runner_fp)/sizeof(struct runners); rewind(runner_fp); runmem_ptr = (struct runners *) malloc(file_size * sizeof(struct runners)); if( runmem_ptr == NULL) mem_error("runners file"); if( fread(runmem_ptr,sizeof(struct runners),file_size,runner_fp) != file_size) read_error("runners file"); *runsize_ptr = file_size; return runmem_ptr; } ERROR MESSAGE! "Need explicit cast to convert int to *void" Any help appreciated. |
December 28, 2002 Re: Its been a while! | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul |
Paul wrote:
> Just getting back into programming, stumped on this error message from some old code I wrote. Function is determing size of memory to allocate.
>
> struct runners * runner_alloc(struct runners *runmem_ptr, long *runsize_ptr,
> FILE *runner_fp)
> {
> long file_size;
>
> if( (fseek(runner_fp,(long) 0 ,SEEK_END)) != NULL) ****** ERROR LINE ******
> {
> move_error("runners file");
> }
>
> file_size = ftell(runner_fp)/sizeof(struct runners);
> rewind(runner_fp);
>
> runmem_ptr = (struct runners *) malloc(file_size * sizeof(struct runners));
>
> if( runmem_ptr == NULL)
> mem_error("runners file");
>
> if( fread(runmem_ptr,sizeof(struct runners),file_size,runner_fp) != file_size)
> read_error("runners file");
>
> *runsize_ptr = file_size;
>
> return runmem_ptr;
> }
>
> ERROR MESSAGE!
>
> "Need explicit cast to convert int to *void"
>
I see messages like this when there is failure to included the appropiate
header file declaring the function malloc, stdlib.h.
--------
Al Bowers
mailto: abowers.combase.com
|
December 28, 2002 Re: Its been a while! | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul | There is insufficient information in your post. But typically such can be caused by calling a function that does not have a declaration for it in scope. -Walter "Paul" <Paul_member@pathlink.com> wrote in message news:auj0n3$2cke$1@digitaldaemon.com... > Just getting back into programming, stumped on this > error message from some old code I wrote. Function > is determing size of memory to allocate. > > struct runners * runner_alloc(struct runners *runmem_ptr, long *runsize_ptr, > FILE *runner_fp) > { > long file_size; > > if( (fseek(runner_fp,(long) 0 ,SEEK_END)) != NULL) ****** ERROR LINE ****** > { > move_error("runners file"); > } > > file_size = ftell(runner_fp)/sizeof(struct runners); > rewind(runner_fp); > > runmem_ptr = (struct runners *) malloc(file_size * sizeof(struct runners)); > > if( runmem_ptr == NULL) > mem_error("runners file"); > > if( fread(runmem_ptr,sizeof(struct runners),file_size,runner_fp) != file_size) > read_error("runners file"); > > *runsize_ptr = file_size; > > return runmem_ptr; > } > > ERROR MESSAGE! > > "Need explicit cast to convert int to *void" > > Any help appreciated. > > |
December 28, 2002 Re: Its been a while! | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul | "Paul" <Paul_member@pathlink.com> wrote: > Just getting back into programming, stumped on this > error message from some old code I wrote. Function > is determing size of memory to allocate. > > struct runners * runner_alloc(struct runners *runmem_ptr, long *runsize_ptr, > FILE *runner_fp) > { > long file_size; > > if( (fseek(runner_fp,(long) 0 ,SEEK_END)) != NULL) ****** ERROR LINE ****** fseek() returns an int, not a pointer. > ERROR MESSAGE! > > "Need explicit cast to convert int to *void" Gisle V. # rm /bin/laden /bin/laden: Not found |
December 29, 2002 Re: Its been a while! | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | Thanks for your help guys. The below problem was solved by changing the error line to:- if( 0 == fseek(runner_fp,0L,SEEK_END)) as fseek returns an int! Thanks for your help, its appreciated. In article <aujcnn$2lct$1@digitaldaemon.com>, Walter says... > >There is insufficient information in your post. But typically such can be caused by calling a function that does not have a declaration for it in scope. -Walter > >"Paul" <Paul_member@pathlink.com> wrote in message news:auj0n3$2cke$1@digitaldaemon.com... >> Just getting back into programming, stumped on this >> error message from some old code I wrote. Function >> is determing size of memory to allocate. >> >> struct runners * runner_alloc(struct runners *runmem_ptr, long >*runsize_ptr, >> FILE *runner_fp) >> { >> long file_size; >> >> if( (fseek(runner_fp,(long) 0 ,SEEK_END)) != NULL) ****** ERROR LINE >****** >> { >> move_error("runners file"); >> } >> >> file_size = ftell(runner_fp)/sizeof(struct runners); >> rewind(runner_fp); >> >> runmem_ptr = (struct runners *) malloc(file_size * sizeof(struct >runners)); >> >> if( runmem_ptr == NULL) >> mem_error("runners file"); >> >> if( fread(runmem_ptr,sizeof(struct runners),file_size,runner_fp) != >file_size) >> read_error("runners file"); >> >> *runsize_ptr = file_size; >> >> return runmem_ptr; >> } >> >> ERROR MESSAGE! >> >> "Need explicit cast to convert int to *void" >> >> Any help appreciated. >> >> > > |
Copyright © 1999-2021 by the D Language Foundation