f



newbie: compile problem with sys/types.h ipv6

Hi,

I'm trying to compile some example code which uses the stat64 function
and the following header files:

#include <sys/types.h>
#include <sys/stat.h>

When I try to build, I get the error message:

c:\0check64\cpp1.cpp(13) : error C2079: 'buf' uses undefined struct
'__stat64'

I'm running Win2K, Microsoft C++ 6.0.


here's the code (very short):

// crt_stat.c
/* This program uses the _stat64 function to
 * report information about the file named stat.c.
 */

#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>

int main( void )
{
   struct __stat64 buf;
   int result;

   /* Get data associated with "crt_stat.c": */
   result = _stat64( "crt_stat.c", &buf );

   /* Check if statistics are valid: */
   if( result != 0 )
      perror( "Problem getting information" );
   else
   {
      /* Output some of the statistics: */
      printf( "File size     : %ld\n", buf.st_size );
      printf( "Drive         : %c:\n", buf.st_dev + 'A' );
      printf( "Time modified : %s", _ctime64( &buf.st_mtime ) );
   }
}

0
chrisrocker90
2/14/2006 7:40:33 PM
comp.os.programmer.win32 14523 articles. 0 followers. Post Follow

1 Replies
436 Views

Similar Articles

[PageSpeed] 34

 You probably got the crt_stat.c sample file from a recent version of
MSDN, and you're trying to compile it under VC 6.0, which doesn't have
the __stat64 structure defined. Use the _stat sample from MSDN October
2001, and it will work under VC6.

Claudiu

chrisrocker90@yahoo.com wrote:
> Hi,
>
> I'm trying to compile some example code which uses the stat64 function
> and the following header files:
>
> #include <sys/types.h>
> #include <sys/stat.h>
>
> When I try to build, I get the error message:
>
> c:\0check64\cpp1.cpp(13) : error C2079: 'buf' uses undefined struct
> '__stat64'
>
> I'm running Win2K, Microsoft C++ 6.0.
>
>
> here's the code (very short):
>
> // crt_stat.c
> /* This program uses the _stat64 function to
>  * report information about the file named stat.c.
>  */
>
> #include <time.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <stdio.h>
>
> int main( void )
> {
>    struct __stat64 buf;
>    int result;
>
>    /* Get data associated with "crt_stat.c": */
>    result = _stat64( "crt_stat.c", &buf );
>
>    /* Check if statistics are valid: */
>    if( result != 0 )
>       perror( "Problem getting information" );
>    else
>    {
>       /* Output some of the statistics: */
>       printf( "File size     : %ld\n", buf.st_size );
>       printf( "Drive         : %c:\n", buf.st_dev + 'A' );
>       printf( "Time modified : %s", _ctime64( &buf.st_mtime ) );
>    }
> }

0
Claudiu
3/10/2006 4:39:07 PM
Reply: