Results 1 to 8 of 8
On linux 2.4, I could do the following with no warnings or errors.
On Linux 2.6 with gcc, it compiles but gives a warning. The created program works.
On Linux ...
- 04-23-2008 #1Just Joined!
- Join Date
- Apr 2008
- Posts
- 5
off_t problem with g++
On linux 2.4, I could do the following with no warnings or errors.
On Linux 2.6 with gcc, it compiles but gives a warning. The created program works.
On Linux 2.6 with g++, it fails compile with an error.
What gives? Anyone know?
Thx,
Jim
My compile is like this:
cc offt.c -D_LARGE_FILES -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -o offt
g++ offt.c -D_LARGE_FILES -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -o offtp
#ifndef WIN32
#include <unistd.h>
#else
#endif
#include <stdlib.h>
#include <stdio.h>
int main( int argc, char *argv[] )
{
#ifdef WIN32
__int64 i64;
#else
off_t offt = 0;
long long lg = 0;
#endif
#ifdef WIN32
i64 = 9223372036854775807;
printf( "i64=%I64d, szi64=%d\n", i64, sizeof(i64) );
#else
offt = 9223372036854775807;
lg = 9223372036854775807;
printf( "offt=%lld, lg=%lld, szofft=%d, szlg=%d\n", offt, lg, sizeof(offt), sizeof(lg) );
#endif
}
- 04-23-2008 #2
Whats the error/warning?
- 04-23-2008 #3Just Joined!
- Join Date
- Apr 2008
- Posts
- 5
Oh right! The warning/error....
With cc:
offt.c: In function ΓÇÿmainΓÇÖ:
offt.c:21: warning: integer constant is too large for ΓÇÿlongΓÇÖ type
offt.c:22: warning: integer constant is too large for ΓÇÿlongΓÇÖ type
With g++:
offt.c:21: error: integer constant is too large for ΓÇÿlongΓÇÖ type
offt.c:22: error: integer constant is too large for ΓÇÿlongΓÇÖ type
It actually shows the funny characters too.
Jim
- 04-23-2008 #4Just Joined!
- Join Date
- Apr 2008
- Posts
- 5
And gcc -v yields: gcc version 4.1.2 20070925 (Red Hat 4.1.2-33)
- 04-23-2008 #5
try ending your long long const 9223372036854775807 with ll
example 9223372036854775807ll;
ll are the letters LL
This tells the compiler that the integers are long long consts
- 04-24-2008 #6Just Joined!
- Join Date
- Apr 2008
- Posts
- 5
Nope. Ending with LL doesn't help.
Thx anyway,
Jim
- 04-24-2008 #7
Thats odd...I copied your code and tried compiling and received the same errors as you, so I appened LL to the long long consts and the compile errors dissappeared.
note I only compiled it in C not C++
- 04-24-2008 #8Just Joined!
- Join Date
- Apr 2008
- Posts
- 5
Oops, my bad. I only did the LL on the off_t variable assignment.
Doing it on both made it work.
Thx,
Hate it when they just change the compiler (or the includes) like that.


Reply With Quote