www.digitalmars.com         C & C++   DMDScript  

c++.dos - Its been a while!

reply Paul <Paul_member pathlink.com> writes:
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.
Dec 27 2002
next sibling parent Al Bowers <abowers combase.com> writes:
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
Dec 27 2002
prev sibling next sibling parent reply "Walter" <walter digitalmars.com> writes:
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.
Dec 27 2002
parent Paul Warren <Paul_member pathlink.com> writes:
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.
Dec 28 2002
prev sibling parent "Gisle Vanem" <giva bgnett.no> writes:
"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. /bin/laden: Not found
Dec 28 2002