[maemo-developers] signedness of char on ARM vs x86
From: Juha Kuikka juha.kuikka at gmail.comDate: Sun Apr 6 08:28:14 EEST 2008
- Previous message: signedness of char on ARM vs x86
- Next message: opencv for arm WAS: signedness of char on ARM vs x86
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Char is indeed unsigned on ARM by default. http://www.arm.linux.org.uk/docs/faqs/signedchar.php You could try to give "-fsigned-char" to gcc when you build your library. - Juha On Sat, Apr 5, 2008 at 9:40 PM, Andrew Daviel <advax at triumf.ca> wrote: > > 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 > _______________________________________________ > maemo-developers mailing list > maemo-developers at maemo.org > https://lists.maemo.org/mailman/listinfo/maemo-developers > -- Madness takes it's toll. Please have exact change. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.maemo.org/pipermail/maemo-developers/attachments/20080405/785318a0/attachment.htm
- Previous message: signedness of char on ARM vs x86
- Next message: opencv for arm WAS: signedness of char on ARM vs x86
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]