[Info-vax] C compiler question

Mark Berryman mark at theberrymans.com
Mon Jul 29 09:59:10 EDT 2019


On 7/28/19 8:57 AM, osuvman50 at gmail.com wrote:
> Usually, the cases where I see that are to due to C header files having differing definitions between systems.

That is sometimes the case.  I see this a lot for functions defined as 
size_t functions, for example.

But what I see the most are functions where the variable is declared as 
unsigned within the function or in the function header, and then signed 
compares are done against that variable.

In all cases where I have encountered it, it is simply lazy programming. 
  Historically, there have been many instances in C where "if (var <= 
0)" was valid for checking for error conditions but this is becoming 
less and less so.  However, some programmers continue to code this way 
and do nothing else.

In most of the code I have been porting, the correct fix has been to 
change if (x <= 0) to if (!x) and, based on how John responded, this is 
something I don't need to worry about anymore.

Mark Berryman



More information about the Info-vax mailing list