ptrdiff_t and gcc 4.1.1

Dries Kimpe Dries.Kimpe at wis.kuleuven.be
Thu Sep 7 16:51:25 CDT 2006


  In June there was a mail on this list mentioning problems with ptrdiff_t and Mac OS X;

Well, the same problem appears with gcc 4.1.1

Trying to compile pnetcdf-1.0.1 gives this error:

make[3]: Entering directory `/home/lts/work/pnetcdf/parallel-netcdf-1.0.1/build/mpich2/src/lib'
mpicc -c -g -O2 -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I.    ../../../../src/lib/mpinetcdf.c
In file included from ../../../../src/lib/nc.h:14,
                 from ../../../../src/lib/mpinetcdf.c:8:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.1/include/stddef.h:152: error: two or more data types in declaration specifiers


ptrdiff_t is defined in stddef.h, which gets included in nc.h, right after it included "ncconfig.h"

==== nc.h ===
...
#include "ncconfig.h"
#include <stddef.h>
...

ncconfig.h #defines ptrdiff_t to be int because the configure test failed to detect ptrdiff_t in stddef.h:
It doesn't detect ptrdiff_t because stddef.h is never included in the test program
(stddef.h is only included when STDC_HEADERS is #defined, which is not the case for the test program)

The configure test looks like this:

conftest.c:88: error: 'ptrdiff_t' undeclared (first use in this function)
conftest.c:88: error: (Each undeclared identifier is reported only once
conftest.c:88: error: for each function it appears in.)
conftest.c:88: error: expected expression before ')' token
configure:7485: $? = 1
configure: failed program was:
| /* confdefs.h.  */
|
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define YYTEXT_POINTER 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_ALLOCA_H 1
| #define HAVE_ALLOCA 1
| #define HAVE_STRUCT_STAT_ST_BLKSIZE 1
| #define HAVE_ST_BLKSIZE 1
| #define HAVE_MPI_COMBINER_DUP 1
| #define HAVE_MPI_COMBINER_HVECTOR_INTEGER 1
| #define HAVE_MPI_COMBINER_HINDEDED_INTEGER 1
| #define HAVE_MPI_COMBINER_SUBARRAY 1
| #define HAVE_MPI_COMBINER_DARRAY 1
| #define HAVE_MPI_COMBINER_RESIZED 1
| #define HAVE_MPI_COMBINER_STRUCT_INTEGER 1
| #define HAVE_MPI_COMBINER_INDEXED_BLOCK 1
| #define HAVE_MPI_COMBINER_F90_REAL 1
| #define HAVE_MPI_COMBINER_F90_INTEGER 1
| #define HAVE_MPI_COMBINER_F90_COMPLEX 1
| #define HAVE_MPI_CHARACTER 1
| #define HAVE_MPI_REAL 1
| #define HAVE_MPI_INTEGER 1
| #define HAVE_MPI_COMPLEX32 1
| #define HAVE_MPI_INTEGER1 1
| #define HAVE_MPI_INTEGER2 1
| #define HAVE_MPI_INTEGER4 1
| #define HAVE_MPI_INTEGER8 1
| #define HAVE_MPI_INTEGER16 1
| #define HAVE_MPI_REAL4 1
| #define HAVE_MPI_REAL8 1
| #define HAVE_MPI_REAL16 1
| #define HAVE_MPI_COMPLEX8 1
| #define HAVE_MPI_COMPLEX16 1
| #define HAVE_MPI_COMPLEX32 1
| /* end confdefs.h.  */
| #include <stdio.h>
| #if HAVE_SYS_TYPES_H
| # include <sys/types.h>
| #endif
| #if HAVE_SYS_STAT_H
| # include <sys/stat.h>
| #endif
| #if STDC_HEADERS
| # include <stdlib.h>
| # include <stddef.h>
| #else
| # if HAVE_STDLIB_H
| #  include <stdlib.h>
| # endif
| #endif
| #if HAVE_STRING_H
| # if !STDC_HEADERS && HAVE_MEMORY_H
| #  include <memory.h>
| # endif
| # include <string.h>
| #endif
| #if HAVE_STRINGS_H
| # include <strings.h>
| #endif
| #if HAVE_INTTYPES_H
| # include <inttypes.h>
| #else
| # if HAVE_STDINT_H
| #  include <stdint.h>
| # endif
| #endif
| #if HAVE_UNISTD_H
| # include <unistd.h>
| #endif
| int
| main ()
| {
| if ((ptrdiff_t *) 0)
|   return 0;
| if (sizeof (ptrdiff_t))
|   return 0;
|   ;
|   return 0;
| }
configure:7508: result: no

workaround on gcc 4 systems: comment out the #define int ptrdiff_t line in ncconfig.h after configuring

  Greetings,
  Dries


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm




More information about the parallel-netcdf mailing list