[Info-vax] C limitations, was: Re: VMS process communication
Johnny Billquist
bqt at softjar.se
Wed Mar 29 11:33:45 EDT 2023
On 2023-03-28 00:59, Arne Vajhøj wrote:
> On 3/27/2023 6:19 PM, Johnny Billquist wrote:
>> On 2023-03-27 15:21, Arne Vajhøj wrote:
>>> On 3/27/2023 8:27 AM, Simon Clubley wrote:
>>>> = for assignment, versus == for comparison. (At least it's not PHP
>>>> however,
>>>> where you need to use === to get a sane comparison. :-))
>>>
>>> C == is not that great either.
>>
>> [...]
>>
>> Not sure I understand what your issue with C == was here.
>> You got a bunch of warnings for comparing mismatching types, which was
>> to be expected. I failed to see any problems beyond that.
>
> It gave warnings on zero int comparison with string and NULL. I
> would prefer an error.
>
> It accepted non-zero int comparison with string and NULL. I would like
> an error.
>
> It accepted int comparison with TRUE/FALSE. I would like
> an error.
Ah. So your complaint was about that. Well, it's not completely unheard
of to actually do such comparisons.
One need to understand that in C, "string" is just syntactic sugar.
When you have a string, in C all you have is an address. And an address
is a number.
So while it seems unlikely that you want to compare the two, it's
possibly something you'd want, hence warning. Same with NULL. It's just
an address, which is a number.
As Simon pointed out, you can request that such warnings be treated as
errors if you want to. But for some, it might actually be very intentional.
>> This has nothing to do with == as such, but with with C type system.
>> This is how the type system is defined to work.
>
> Yes - a lot of it is due to the type system.
And I think that in this case, it's not completely unreasonable how it
handles things. I consider a warning to be a good thing here. It might
be what the author intended. If so, he might want to rephrase it to not
get the warnings, or else consider the warnings as something flagging a
potential error.
It is not absolutely certain that this actually is an error. The author
needs to figure that out. The compiler can not.
Johnny
More information about the Info-vax
mailing list