This is a discussion on Re: char signed or unsinged ? (was Netscape 7 issues) within the AIX Operating System forums, part of the Unix Operating Systems category; --> "Dr. David Kirkby" wrote: > char foo; > > is asking for trouble, if you hope to put negative ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| "Dr. David Kirkby" wrote: > char foo; > > is asking for trouble, if you hope to put negative numbers in foo. Indeed. The Standard leaves it unspecified whether an unadorned char is signed or unsigned. -- Erik Max Francis && max@alcyone.com && http://www.alcyone.com/max/ __ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE / \ You win the victory when you yield to friends. \__/ Sophocles |
| |||
| Erik Max Francis wrote: > > "Dr. David Kirkby" wrote: > > > char foo; > > > > is asking for trouble, if you hope to put negative numbers in foo. > > Indeed. The Standard leaves it unspecified whether an unadorned char is > signed or unsigned. I've just confirmed that AIX and IRIX declare it unsigned, whereas Solaris, Linux, AIX, HP-UX, Tru64, NetBSD, OpenBSD all declare it signed. Although I've not had chance to fix the problem yet, I think that explains why my program for computing the properties of transmission lines http://atlc.sourceforge.net/ works on Solaris, Linux, AIX, HP-UX, Tru64, NetBSD, OpenBSD, but not on AIX or IRIX. At least fixing it should not be too hard - just needs a bit of time. -- Dr. David Kirkby, Senior Research Fellow, Department of Medical Physics, University College London, 11-20 Capper St, London, WC1E 6JA. Tel: 020 7679 6408 Fax: 020 7679 6269 Internal telephone: ext 46408 e-mail davek@medphys.ucl.ac.uk |
| |||
| "Dr. David Kirkby" wrote: > I've just confirmed that AIX and IRIX declare it unsigned, whereas > Solaris, Linux, AIX, HP-UX, Tru64, NetBSD, OpenBSD all declare it > signed. Sorry, AIX considers it unsigned. -- Dr. David Kirkby, Senior Research Fellow, Department of Medical Physics, University College London, 11-20 Capper St, London, WC1E 6JA. Tel: 020 7679 6408 Fax: 020 7679 6269 Internal telephone: ext 46408 e-mail davek@medphys.ucl.ac.uk |
| |||
| In article <3F14007C.92A259E7@marconi.com>, John Howells <John.Howells@marconi.com> wrote: >"Dr. David Kirkby" wrote: >> Sorry, AIX considers it unsigned. > >You have to be careful in saying that, as in principle it is the >compiler that matters, not the platform. It might be unwise to break the >platform convention, but in theory one compiler might use signed and one >unsigned on the same platform. I would expect this to be treated as part of the platform's ABI, which all compilers for the platform should conform to. This is because the OS vendor provides header files for their system call and runtime libraries, and all hell would break loose if these headers were interpreted differently by different compilers. -- Barry Margolin, barry.margolin@level3.com Level(3), Woburn, MA *** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups. Please DON'T copy followups to me -- I'll assume it wasn't posted to the group. |
| |||
| "Dr. David Kirkby" <drkirkby@ntlworld.com> writes: >I've just confirmed that AIX and IRIX declare it unsigned, whereas >Solaris, Linux, AIX, HP-UX, Tru64, NetBSD, OpenBSD all declare it >signed. At least in the case of Linux, it depends very much on the platform: GCC on Linux defaults to signed char e.g. on i386, ia64, alpha, sparc, mips, but to unsigned char e.g. on powerpc, s390, arm ... -- Dr. Ulrich Weigand weigand@informatik.uni-erlangen.de |
| |||
| "Dr. David Kirkby" wrote: > I've just confirmed that AIX and IRIX declare it unsigned, whereas > Solaris, Linux, AIX, HP-UX, Tru64, NetBSD, OpenBSD all declare it > signed. The point is, the standard declares it implementation defined. Thus if you ever need it to be either signed or unsigned, using an andorned char is a programming error. -- Erik Max Francis && max@alcyone.com && http://www.alcyone.com/max/ __ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE / \ Nine worlds I remember. \__/ Icelandic Edda of Snorri Sturluson |
| |||
| John Howells wrote: > You have to be careful in saying that, as in principle it is the > compiler that matters, not the platform. It might be unwise to break > the > platform convention, but in theory one compiler might use signed and > one > unsigned on the same platform. Or, indeed, signed in one _version_ and unsigned in the next! That would be particularly obtuse, but there's nothing in the Standard preventing it. The point here is that if you need some guarantee and the Standard doesn't make it, don't look surprised when you get screwed. -- Erik Max Francis && max@alcyone.com && http://www.alcyone.com/max/ __ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE / \ Nine worlds I remember. \__/ Icelandic Edda of Snorri Sturluson |
| |||
| "Dr. David Kirkby" schrieb: > > > I've just confirmed that AIX and IRIX declare it unsigned, whereas > > Solaris, Linux, AIX, HP-UX, Tru64, NetBSD, OpenBSD all declare it > > signed. > > Sorry, AIX considers it unsigned. As nobody seems to have mentioned it, this is just a default. You may change it by adding "-qchars=signed" to the options in /etc/xlC.cfg. HTH, Joe -- Josef Walzer Messerli Informatik GmbH, Hamoderstr. 4, A-4020 Linz http:://www.messerli.at |
| ||||
| Josef Walzer wrote: > > "Dr. David Kirkby" schrieb: > > > > > I've just confirmed that AIX and IRIX declare it unsigned, whereas > > > Solaris, Linux, AIX, HP-UX, Tru64, NetBSD, OpenBSD all declare it > > > signed. > > > > Sorry, AIX considers it unsigned. > As nobody seems to have mentioned it, this is just a default. > You may change it by adding "-qchars=signed" to the options in /etc/xlC.cfg. > > HTH, > Joe Thanks, but it was basically a bit of dodgy programming on my part to write a program that needed a signed char, but did not explisitly state it. Having to configure the compiler is okay if you know the problem, but is hardly a very good way to distribute code. Hence I've changed the code. -- Dr. David Kirkby, Senior Research Fellow, Department of Medical Physics, University College London, 11-20 Capper St, London, WC1E 6JA. Tel: 020 7679 6408 Fax: 020 7679 6269 Internal telephone: ext 46408 e-mail davek@medphys.ucl.ac.uk |