Who collects programs under g ++? How to get the lseek64 function? although it is spelled out in io.h, it is not located. error: `lseek64 'undeclared (first use this function).

Also, I cannot use struct stat64; When you try to create a function that returns this structure, errors appear: error: return type struct stat64' is incomplete. error: aggregate struct stat64' is incomplete. error: aggregate stat64 st 'has incomplete type and cannot be defined.

And is there a define by which it can be determined that g ++ is running in Windows?

  • one
    Define there. touch foo.h; cpp -dM foo.h will show all the predefined macros. - alexlz
  • Is unistd.h included? - skegg
  • Define WIN32, yes \ #include <unistd.h> use long long for the result and offset in the program - avp
  • WIN32 and _WIN32 defaults are not seen. I have a mingw. #include <unistd.h> is. Share the project in which it all works. - mikelsv
  • The project in which it all works: Linux - skegg

1 answer 1

@mikelsv , in my Windows-7 MinGW

 #include <stdio.h> #include <stdlib.h> #include <unistd.h> main () { #ifdef WIN32 puts("win"); #endif long long rc = lseek64(0,(long long)100,SEEK_CUR); printf ("rc = %lld\n",rc); } 

launch

 c:/Users/avp/src/cc/tst $ g++ t1.c c:/Users/avp/src/cc/tst $ ./a win rc = 100 c:/Users/avp/src/cc/tst $ g++ --version g++.exe (GCC) 3.4.5 (mingw-vista special r3) Copyright (C) 2004 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. c:/Users/avp/src/cc/tst $ gcc t1.c c:/Users/avp/src/cc/tst $ ./a win rc = 100 c:/Users/avp/src/cc/tst $ gcc --version gcc.exe (GCC) 3.4.5 (mingw-vista special r3) Copyright (C) 2004 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. c:/Users/avp/src/cc/tst $ 
  • It worked. But now the plug on the function getaddrinfo (). Connected #include "ws2tcpip.h", no result. Even if you register her ad, ld does not find it. Ws2_32.lib connect. - mikelsv
  • @mikelsv you have a very interesting compiler. I myself have never seen such a message - “plugging”. - alexlz
  • @ mikelsv, I don't have one either. In .h there is the text #if (_WIN32_WINNT> = 0x0501) .... I think my version is also not the same. And why do you need a Windows? - avp
  • I suspect the only option is to directly pull getaddrinfo () from the dll. In the Makefile can you somehow determine that it is running in mingw-make? I tried ifdef WIN32, but it did not work. If there is an opportunity to build a program in Windows, then I want to use this opportunity. Build in g ++. The MSVS is going without problems. - mikelsv
  • @mikelsv, I use ifdef _ # * nix in the Makefile to distinguish between Windows / * nix PWD = pwd DEL = rm -f NULL = / dev / null .... else # win PWD = cd DEL = del / f NULL = nul .... endif at the beginning of the file. - avp