So this is the requirement asked by our professor, we need to use c89
standard (there is no long long
type). And in linux before compile we have to use -ansi
flag.
I prefer to debug in Windows first using VS Code, however one day I notice long overflow then I just realised the long of gcc in x64 windows is 4 byte, in x64 linux gcc long
is 8 byte.
- I am very sure the installation that I've chosen is x86_64
- How I knew it's 4 byte by running
printf("The size of long is: %d\n", (int)sizeof(long));
Do I need to add any command line flag to gcc to make the size of long
become 8bit?
What can I do to make the GCC reserve long
as 8 byte?
Btw I open the header file and I saw this
What is this
C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\x86_64-w64-mingw32\include\_mingw.h
I tried to change to
#ifndef __LP64__ /* 32 bit target, 64 bit Mingw target */
#define __int64 long
#else /* 64 bit Cygwin target */
#define __LONG32 int
#endif
But it didn't work somehow