[maemo-developers] signedness of char on ARM vs x86
From: Andrew Daviel advax at triumf.caDate: Sun Apr 6 07:40:11 EEST 2008
- Previous message: [Announce] Release of the DCCP Plugin 0.5 for GStreamer
- Next message: signedness of char on ARM vs x86
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I have been trying to compile the opencv library for my N810 using
scratchbox. My application is OK on x86 and compiles but doesn't work on
ARM, and I find
some of the library functions returning different results with supposedly
identical data. Going back over the library build I find some compiler
warnings such as
warning: comparison is always false due to limited range of data type
warning: converting of negative value `-0x00000000000000001' to `char'
After some time tracing back data include files and defines I find
that some modules in the library are doing arithmetic with char, and the
compiler spots e.g. static comparisons.
The following snippet shows the problem:
#include "stdio.h"
int main() {
int j = -2 ;
char k ;
unsigned char m ;
signed char n ;
m = j ; n = j ; k = j ;
if (j < 0) printf ("j < 0\n" ) ;
if (k < 0) printf ("k < 0\n" ) ;
if (m < 0) printf ("m < 0\n" ) ;
if (n < 0) printf ("n < 0\n" ) ;
}
On my i386 desktop, with gcc 4.0.2 or 3.2.3, k < 0
In scratchbox-ARMEL, with gcc 3.4.4, k > 0
By which I presume that "char" is signed on the 386 and unsigned on the
ARM.
Is there any way I can override the compiler default, or do I have to go
through everything by hand and see where char is used inappropriately ?
How general is this, that data types are different on different systems
(I know about the int/long issues on 64-bit machines ...) ?
--
Andrew Daviel, TRIUMF, Canada
Tel. +1 (604) 222-7376 (Pacific Time)
Network Security Manager
- Previous message: [Announce] Release of the DCCP Plugin 0.5 for GStreamer
- Next message: signedness of char on ARM vs x86
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
