On Fri 2008-12-05 23:06:21 UTC-0000, step0ut ([EMAIL PROTECTED]) wrote:

> I got a code written in C, it makes use of the type:
> long long int

You can abbreviate this to just "long long".

> code compiles fine with gcc, I am using gcc version 4.1.2 20070626
> 
> I would like however to compile the code with g++ believing it is a
> more strict compiler and since
> I feel more used to c++ code.
> Anyway... one of the things the compiler was complaining is the use of
> the "long long int" type.
> 
> For example at some point there was the line:
> long long int slot_pattern = 0ll;

Works for me.

$cat long-long-test.cpp
long long int slot_pattern = 0ll;

$make long-long-test.o
c++ -O2 -fno-strict-aliasing -pipe -c long-long-test.cpp

$gcc -v
Using built-in specs.
Configured with: FreeBSD/i386 system compiler
Thread model: posix
gcc version 3.4.6 [FreeBSD] 20060305

> Ok I found that C++ does not yet support this type,

Not quite.  "long long" is a common extension to C & C++, provided by
some compiler suites.

> however adding the -Wno-long-long flag in my ccflags: -pedantic -g
> -D_FILE_OFFSET_BITS=64 -Wno-long-long -fPIC
> 
> the code compiles fine in a 64 bit machine but in a 32 bit machine I
> get the following error:
> error: integer constant is too large for 'long' type

Then you have made a mistake in your code.  The compiler is telling
you that you have a 'long'.  But you say you are specifying a 'long
long'.  Both can't be true.

> Now my questions are:
> 1) The fact that it compiles in the 64 bit machine does it mean that
> it actually uses correctly the long long int type?
> 2) How can one solve the problem on the 32 bit machine.

I assume the problem is that you want 64-bit integers on a 32-bit
machine.  FreeBSD provides a int64_t datatype.  Your platform (Linux?)
will probably have something similar.

Reply via email to