Signedness of "char" 
Author Message
 Signedness of "char"

Dear all,

I am working with a Pascal-to-C source code translator
(on several Unix and Win platforms)
that transforms a Pascal "char" to a C "unsigned char".

As can be expected, this causes type checking problems
with basic operating system functions (and C builtins)
that are defined on C "char", leaving signedness unspecified.

Setting aside arithmetic questions,
is there any reason to treat a Pascal "char" as "unsigned" ?

Thank you for all hints,

Joerg Bruehe

--
Joerg Bruehe, SQL Datenbanksysteme GmbH, Berlin, Germany
     (speaking only for himself)



Tue, 18 Nov 2003 19:03:09 GMT  
 Signedness of "char"

Quote:

>Dear all,

>I am working with a Pascal-to-C source code translator
>(on several Unix and Win platforms)
>that transforms a Pascal "char" to a C "unsigned char".

>As can be expected, this causes type checking problems
>with basic operating system functions (and C builtins)
>that are defined on C "char", leaving signedness unspecified.

>Setting aside arithmetic questions,
>is there any reason to treat a Pascal "char" as "unsigned" ?

If you ask for the successor of char(128), you want char(129), not an
overflow or range error.  C has no concept of "successor", so it's not
an issue there.  

Duncan Murdoch



Tue, 18 Nov 2003 19:52:50 GMT  
 Signedness of "char"

Quote:

> Dear all,

> I am working with a Pascal-to-C source code translator
> (on several Unix and Win platforms)
> that transforms a Pascal "char" to a C "unsigned char".

> As can be expected, this causes type checking problems
> with basic operating system functions (and C builtins)
> that are defined on C "char", leaving signedness unspecified.

> Setting aside arithmetic questions,
> is there any reason to treat a Pascal "char" as "unsigned" ?

> Thank you for all hints,

What are you going to do with:

var c:char;
    i:integer;

begin
 c:=#128;
 i:=ORD(c);
end.

?



Tue, 18 Nov 2003 20:56:46 GMT  
 Signedness of "char"

Quote:

>Dear all,

>I am working with a Pascal-to-C source code translator
>(on several Unix and Win platforms)
>that transforms a Pascal "char" to a C "unsigned char".

>As can be expected, this causes type checking problems
>with basic operating system functions (and C builtins)
>that are defined on C "char", leaving signedness unspecified.

>Setting aside arithmetic questions,
>is there any reason to treat a Pascal "char" as "unsigned" ?

Well, in Pascal a char is what the name says, a "character", meaning
it's a value out of the 256 byte character range. Pascal is more
specific here (and doesn't assume only 7 bit ASCII, which is nice for
any non-US/english application).


Wed, 19 Nov 2003 00:14:48 GMT  
 Signedness of "char"
As long as you don't use any character above 128, there is no
problem with signed char status, beyond the problems allways
inherent to C with such types. Signed chars are the original standard,
and where there because one of the first machines C compiled
for had signed math, thats it, thats all, so there was no such thing
as unsigned chars. I think the idea was that if you got used
to working with signed chars that you would be good to go
on either signed or unsigned char implementations.

Quote:

> Dear all,

> I am working with a Pascal-to-C source code translator
> (on several Unix and Win platforms)
> that transforms a Pascal "char" to a C "unsigned char".

> As can be expected, this causes type checking problems
> with basic operating system functions (and C builtins)
> that are defined on C "char", leaving signedness unspecified.

> Setting aside arithmetic questions,
> is there any reason to treat a Pascal "char" as "unsigned" ?

> Thank you for all hints,

> Joerg Bruehe

> --
> Joerg Bruehe, SQL Datenbanksysteme GmbH, Berlin, Germany
>      (speaking only for himself)


--
"I'd like to see cpp abolished" - Bjarne Stroustrup
[cpp is the original name of C PreProcessor]


Wed, 19 Nov 2003 03:40:16 GMT  
 Signedness of "char"
Unless you are talking about a particular implementation of Pascal, as I am
sure you are (say so !) there is no such rule. The underlying character set
in Pasal is not stated to be any particular type or number of codes.

If you are instead discussing Borland Pascal, the statement is correct.

Quote:

> Well, in Pascal a char is what the name says, a "character", meaning
> it's a value out of the 256 byte character range. Pascal is more
> specific here (and doesn't assume only 7 bit ASCII, which is nice for
> any non-US/english application).

--
"I'd like to see cpp abolished" - Bjarne Stroustrup
[cpp is the original name of C PreProcessor]


Wed, 19 Nov 2003 03:42:38 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. The keys "-"/"+"/"*"

2. "Invalid Char in Field" error

3. ""256 Color Mouse""

4. What are "Denormals" and "Nans"

5. Utility to convert "asm" to "inline( )"

6. "delete from" followed by "insert into" = AV

7. "Replace Connection", "Unable to connect to: PARADOX".

8. HELP!!: "Multiple net files","Lock file has grown too large"

9. A problem in creating equal sized "packets" from a set of "packages".

10. How to make a "xxx.EXE" from the "xxx.PAS"???

11. "blob" and "DBT" file errors

12. ComboBox that shows "Name" and returns "Value"?

 

 
Powered by phpBB® Forum Software