Can't return signed longs from .c
BlitzMax Forums/BlitzMax Programming/Can't return signed longs from .c
| ||
Hi, I was messing with hires timers which use longs. I can't return a signed long from some .c code, am I doing something wrong? This won't even return 1, let alone 9223372036854775807. If I change ReturnLong:Long() to ReturnLong:Int() I get '4147483647' Cheers Tom .C //longtest.c signed int ReturnInt() { return 2147483647; } signed long ReturnLong() { return 1; //9223372036854775807; } B'Max Import "longtest.c" Extern Function ReturnInt:Int() Function ReturnLong:Long() End Extern i:Int = ReturnInt() t:Long = ReturnLong() Print i '2147483647 Print t 'always 0 ? |
| ||
long in c isn't the same as in blitzmax, use 'long long'. |
| ||
Not sure if you meant long long in C or B'Max, either way doesn't work though. Edit: If I change it to this signed long ReturnLong() { return (signed long)9223372036854775807; } I get 1 error: C:/blitzmax/samples/longtest.c:8: warning: integer constant is too large for "long" type return (signed long)9223372036854775807; is line 8 |
| ||
In c i meant. signed long long ReturnLong() { return 9223372036854775807; } |
| ||
Yeh I tried that too, doesn't work. |
| ||
Longs are returned 'struct style' in Max, eg: C Code: #include <brl.mod/blitz.mod/blitz.h> void bbLongTest( BBInt64 *r,BBInt64 x,BBInt64 y ){ *r=x+y; } Max Code: Import "ccode.c" Extern Function bbLongTest:Long( x:Long,y:Long ) End Extern Print bbLongTest( 10,20 ) |