gcc 4.2.x large file support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I think I have found a problem in the g++ header files concerning large file
support.  I have seen it on two different AIX machines, one running AIX 5.3
and using gcc 4.1.2, the other running AIX 5.2 and using a slightly later
version of gcc, namely 4.2.2.

cstdio carefully #undefs all the routines in stdio.h and then issues a
"using" directive for each.  The problem is that when large file support is
enabled, routines like fgetpos() have been remapped to the 64-bit
equivalents, fgetpos64() in this example.

>From stdio.h:

	#ifdef _LARGE_FILES
	  #define fgetpos fgetpos64
	#endif

	#ifdef _LARGE_FILE_API
	   extern int fgetpos64(FILE *, fpos64_t *);
	#endif


Then cstdio does

	#undef fgetpos

and later ...

	using ::fgetpos;

which yields a compilation error because there is no such routine.

The following source code illustrates the problem.

testio.cpp
==========

#include <cstdio>

int main(int argc, char *argv[])
{
   FILE
      *ff;

   ff = fopen("grober.nix", "w");
   if (ff == 0)
   {
      puts("File open failed");
   }
   else
   {
      fprintf(ff, "To a %s, happiness is a warm %s\n",
                       "maggot", "cowpat");
                fclose(ff);
   }
   return 0;
}

When compiled with:
   g++ testio.cpp
no error is elicited and the program (a.out) does what is expected.
Compiling with
   g++ -D_LARGE_FILES testio.cpp
yields

In file included from testio.cpp:1:
/opt/freeware/lib/gcc/powerpc-ibm-aix5.2.0.0/4.2.2/include/c++/cstdio:109:
error: '::fgetpos' has not been declared
/opt/freeware/lib/gcc/powerpc-ibm-aix5.2.0.0/4.2.2/include/c++/cstdio:111:
error: '::fopen' has not been declared
/opt/freeware/lib/gcc/powerpc-ibm-aix5.2.0.0/4.2.2/include/c++/cstdio:116:
error: '::freopen' has not been declared
/opt/freeware/lib/gcc/powerpc-ibm-aix5.2.0.0/4.2.2/include/c++/cstdio:119:
error: '::fsetpos' has not been declared
testio.cpp: In function 'int main(int, char**)':
testio.cpp:8: error: 'fopen' was not declared in this scope

All the routines listed in the error messages are subject to the 64-bit
remapping done by stdio.h and broken by cstdio.

Now I tried the same thing on some other platforms, namely
   HPUX ia64	g++ 4.2.2
   HPUX parisc	g++ 4.2.2
   Linux x86_64	g++ 3.4.5
   Linux x86	g++ 3.4.6
and none of those exhibited the problem described above.  I confess that I
do not know why, and it suggests that either my analysis is flawed or the
large file support is not being used by C++ programs on those platforms.

(I noted that _LARGE_FILES and _LARGE_FILE_API are disjoint but I did not
spend any time trying to figure out why.)


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux