[ back to toc ]

data types

Date: 2002/02/04 16:53

Q:
Hey there,

I'm having problems with a long...
In the .h file it has this...

struct.h:

#define MODE_1 0x00000001
#define MODE_2 0x00000002
...
#define MODE_A 0x80000000

long mode;

In the .c file:

int modes[] = {
MODE_1, '1',
MODE_2, '2',
..
MODE_A, 'A',
0, 0
};

When I add a #define MODE_B 0x100000000 in the .h file and add MODE_B,
'B', in the .c file, my compiler spits errors out and the additional bit
of code doesn't work at all.

Errors are :

"Warning: Assignment from incompatible pointer type" and "Warning:
Overflow in implicit constant conversion"

The above is displayed when I set the .h file 'long' to be a 'long int'
and the .c file 'long mode[]' to be a 'long int mode[]'.

I've been told I need to change this long to something else (which is part
of a struct and is used to store these MODE_ values), however my knowledge
of C isn't too fantastic, I've tried a long int and various incantations
of the above but no success. Do you have any ideas of how I can turn this
32-bit long into a 64-bit? I don't want to add a second 'long' just to
handle the overflow, would rather have it as 1 value, not 2.

Using Linux Mandrake 8.1, GCC 2.96 with GLIBC. I guess this is ANSI C.
A:
Try to use

long long

Regards,
Peter

[ back to toc ]