FreeBSD raspberry pi C compiler strangeness

George Mitchell george+freebsd at m5p.com
Wed Feb 26 19:52:47 UTC 2020


On 2020-02-26 14:45, Wojciech Puchar wrote:
> i wrote my program and tested completely my program on x64 laptop under
> FreeBSD 11
> 
> then i compiled this program under FreeBSD on raspberry pi (quite latest
> version downloaded less than 2 months ago).
> 
> And program didn't work properly.
> 
> Finally i found a problem.
> 
> char is signed by default on x64.
> 
> On raspberry pi char is unsigned by default.
> replacing "char" with "signed char" fixed problem completely.
> 
> Why char is unsigned on FreeBSD/raspberry pi?
> [...]

Because the C standard explicitly doesn't say.  The standard DOES
explicitly say that char, signed char, and unsigned char are
considered to be three distinct types, no two of which are
necessarily comparable.  The bottom line is that you are asking for
trouble by ever specifying "char" as a type, and you should always
specify either "signed char" "unsigned char" as appropriate for
the given situation.                                  -- George

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20200226/91739115/attachment.sig>


More information about the freebsd-hackers mailing list