CMake netCDF Compatibility with WPS (#2121)
[WRF.git] / tools / fseek_test.c
blob45cccef22f61ff2aca35c85bda03472fd0990013
1 #define _FILE_OFFSET_BITS 64
2 #ifndef FILE_TO_TEST
3 #define FILE_TO_TEST "Makefile"
4 #endif
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <errno.h>
8 #include <sys/types.h>
9 int
10 main()
12 FILE *fp ;
13 long long y ;
14 int retval ;
15 int result1 ;
16 #ifdef TEST_FSEEKO
17 off_t x ;
18 off_t result2 ;
19 #endif
20 #ifdef TEST_FSEEKO64
21 long long x ;
22 int result2 ;
23 #endif
24 fp = NULL ;
25 fp = fopen( FILE_TO_TEST , "r" ) ;
26 #ifdef TEST_FSEEKO
27 x = 0xffffffff ;
28 result1 = (sizeof(x) == 8) ;
29 result2 = fseeko( fp, x, SEEK_SET ) ;
30 #endif
31 #ifdef TEST_FSEEKO64
32 x = 0xffffffffL ;
33 result1 = (sizeof(x) == 8) ;
34 result2 = fseeko64( fp, x, SEEK_SET ) ;
35 #endif
36 if ( result2 ) perror("error") ;
37 fprintf(stdout,"pointer is 8 bytes: %s\n",result1?"true":"false") ;
38 fprintf(stdout,"seek returns correctly: %s\n",!result2?"true":"false") ;
39 if ( result1 && !result2 ) {
40 fprintf(stdout,"status: OK\n") ;
41 retval = 0 ;
42 } else {
43 fprintf(stdout,"status: BUMMER\n") ;
44 retval = 1 ;
46 fclose(fp) ;
47 return retval ;