[freetds] [PATCH] VMS build update

Craig A. Berry craigberry at mac.com
Sat Nov 6 17:48:40 EST 2004


James K. Lowden wrote:
> - if (freopen(options.input_filename, "r", stdin) < 0) {
> + if ((int)freopen(options.input_filename, "r", stdin) < 0) {
> 
> Could I change all these to:
> 
> if (freopen(options.input_filename, "r", stdin) < (FILE*)0) {
> 
> I think that's more honest.  

It looks like the compiler will take that, though it surprises me that
it doesn't complain about comparing zero to an unsigned value. A pointer
can't be negative can it?

> BTW, does "< NULL" work better?  

No, it doesn't like that:

                 if (freopen(options.output_filename, "w", stdout) < NULL) {
....................^
%CC-W-CVTDIFTYPES, In this statement, "((void ...)0)" of type "pointer 
to void", is being converted to "pointer to pointer to struct _iobuf".

> Similarly, 
> 
> - if (options.verbose < 0) {
> + if ((int)options.verbose < 0) {
> 
> oughta be
> 
> if (options.verbose < (FILE*)0) {

The compiler takes this without complaint.

HOWEVER, as I belatedly look at the docs, my CRTL documentation and C99
agree that fopen and freopen both return NULL on failure, not a negative
number. So apparently what we really should be discussing is changing
them all to "== (FILE*)NULL".


More information about the FreeTDS mailing list