[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Antw: Re: anacron madness



Hi !

The problem with anacron not working is, that at least under the current gcc/libc combo
a comparison like       while ((a=getchar())!=EOF) does not work correctly for a char type a. If you change the type to int or specify -fsigned-char as a compiler option or make an explicit cast to int, everything works. The reason for that is that by default the current egcs uses unsigned chars, unless specified
differently.
In anacron, instead of the more frequently used getchar, the getopt function is used (main.c: line 93).
The behaviour is, however, jsutr the same.

You*ll encounter this problem quite frequently when compiling stuff for ppc. Use -Wsign-compare to be warned about construkts like that. Warnings will look like:
   comparison is alway 1 due to limited range of data type
  comparison between signed and unsigned

You should look into any of those warnings to check whether things are done correctly.

For the book, a comparison like the one mentioned above is not correct programming style
for several reasons. Please use the correct types or explicit casts when mixing function evaluations
and comparisons.

 Helmut
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    *****************************************************
HELMUT GEYER
DFS Deutsche Flugsicherung GmbH
Kaiserleistrasse 29-35
D-63067 Offenbach
Phone: +49-69-8054-0
Internet Address: helmut.geyer@dfs.de
Home Page: http://www.dfs.de
*****************************************************
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: PGPsdk version 1.1.1 (C) 1997 Pretty Good Privacy, Inc.

mQCNAzXF2jUAAAEEAKxUZcxbNC7MSArkE5H+WKkA9aKVTFbrTaOkmO0WZ2RFmgxZ
tMYna0G/htahCCwuF3e1HgfJpz5Xx1x0Rln/vWgRNCg0tKVW+4eF/lDuy5kFgGIJ
Z9Rwq/knoLkiRCncVkI6dGXarmZFiZom/SaUlQCizuK6L61QgYOTple318bpAAUR
tCBEZXV0c2NoZSBGbHVnc2ljaGVydW5nIDxAZGZzLmRlPokAlQMFEDXF2jWDk6ZX
t9fG6QEBOhMD/2JILa21XXDbws3gyBW/JDp6jF7pRGzFxf9K8MTWQJ+hX2ujmb42
lvFXUU5gP5vQXNa0ibABODjvbsWZiL6v7tiZRsAYuWWzIGF5KEBUcQK+d4+TMELQ
DuYMdzhPnhLbCwuA/uGOWCfJ+GBLFoog97TLCsBpM76UkBKGFuSdFJp5
=wE3x
-----END PGP PUBLIC KEY BLOCK-----



Reply to: