min/max in stdlib.h?!

H

Harald van Dijk

What Navia and/or Microsoft do has nothing whatsoever to do with it.

What jacob navia and Microsoft do has everything to do with whether their
implementations conform to the C standard.
 
B

Ben Bacarisse

CBFalconer said:
anything at all.

Just plain 'doesn't work'. Lookup the return value of puts.

It works fine. I think you missed the point of the example (now lost
since you snipped the key part).
 
S

Serve Lau

CBFalconer said:
What Navia and/or Microsoft do has nothing whatsoever to do with
it. Simply read the C standard, or something reasonably close,
such as N869 or N1276.

lccwin32 follows msvc as a windows development tool. If microsoft followed
the C standard back in 1998 when they introduced msvc6, lccwin32 wouldnt
have had min and max in stdlib either.
They should have followed the standard yes, but lccwin32 tries to have
software compatible with microsoft's tools above all (correct me if I'm
wrong) It isnt so strange for a windows compiler (lccwin32) to follow the
most used windows development tool for C in the world (msvc)
 
J

jacob navia

Serve said:
lccwin32 follows msvc as a windows development tool. If microsoft
followed the C standard back in 1998 when they introduced msvc6,
lccwin32 wouldnt have had min and max in stdlib either.
They should have followed the standard yes, but lccwin32 tries to have
software compatible with microsoft's tools above all (correct me if I'm
wrong) It isnt so strange for a windows compiler (lccwin32) to follow
the most used windows development tool for C in the world (msvc)

Well that is exactly the position I had. I tried to be compatible with
what Microsoft said.

I remember when I started writing those headers, and my frame of mind at
that time wasn't really a "language lawyer" mindset. I saw it in the
stdlib.h from msvc 4.1 (if I remember correctly) I said myself that
those are useful macros, I put them there, and there they stayed
until now. This user has seen this problem, and I thank him
for this bug report.

The "regulars" now will start turning this bug around for decades
(like Mr Heathfield that said that lcc-win did not have a conforming
mode because of this bug) but this is just BORING polemic guys.

You will have to find something more substantial to go on.

Anyway I will put the correction this evening so they will not
have so much time to go on...

:)
 
C

CBFalconer

jacob said:
.... snip ...

Well that is exactly the position I had. I tried to be compatible
with what Microsoft said.

I remember when I started writing those headers, and my frame of
mind at that time wasn't really a "language lawyer" mindset. I saw
it in the stdlib.h from msvc 4.1 (if I remember correctly) I said
myself that those are useful macros, I put them there, and there
they stayed until now. This user has seen this problem, and I
thank him for this bug report.

You forgot to add that you disovered c.l.c and have become more
alert to what the standard says. That would have been much more
useful than what you did say.
 
C

CBFalconer

Ben said:
It works fine. I think you missed the point of the example (now
lost since you snipped the key part).

I don't think there is any argument that "max(a, b)" should return
one of the values a or b. However the above returns the return
from puts, which is (from N869):

7.19.7.10 The puts function

Synopsis
[#1]
#include <stdio.h>
int puts(const char *s);

Description

[#2] The puts function writes the string pointed to by s to
the stream pointed to by stdout, and appends a new-line
character to the output. The terminating null character is
not written.

Returns

[#3] The puts function returns EOF if a write error occurs;
otherwise it returns a nonnegative value.
 
F

Flash Gordon

CBFalconer wrote, On 06/01/08 22:31:
I don't think there is any argument that "max(a, b)" should return
one of the values a or b.

<snip irrelevant material>

Yes there is. The one Ben wrote should *not* return either a or b. The
entire point was that the behaviour would be different if stdlib.h
defines max.
 
B

Ben Bacarisse

CBFalconer said:
I don't think there is any argument that "max(a, b)" should return
one of the values a or b.

max(a, b) can return whatever that author wants it to. The example
was intended to show that it matters where and when macros are
defined.
from puts, which is (from N869):

Yes, I know what puts returns and I am sure Army1987 does too. The
same point could have been made using

int max(int a, int b) { return 42; }

or

int max(int a, int b) { puts("In my own max."); return a > b ? a : b; }
 
B

Ben Bacarisse

Flash Gordon said:
CBFalconer wrote, On 06/01/08 22:31:

<snip irrelevant material>

Yes there is. The one Ben wrote should *not* return either a or b. The
entire point was that the behaviour would be different if stdlib.h
defines max.

It was Army1987 not me. I just "stepped up" when the example was
misinterpreted.
 
C

CBFalconer

Ben said:
It was Army1987 not me. I just "stepped up" when the example was
misinterpreted.

One thing is sure - that I regret having pointed anything out about
it, The resultant furor is not worth the <paper> it is written on.
:)
 
F

Flash Gordon

Ben Bacarisse wrote, On 07/01/08 00:59:
It was Army1987 not me. I just "stepped up" when the example was
misinterpreted.

Sorry, I didn't look far enough in to the quoting.
 
D

David Thompson

What Navia and/or Microsoft do has nothing whatsoever to do with
it. Simply read the C standard, or something reasonably close,
such as N869 or N1276.
N1256 .

- formerly david.thompson1 || achar(64) || worldnet.att.net
 
C

CBFalconer

David said:

Which doesn't have a greppable (etc.) text version, which N869
does. In fact you can get N869.txt compressed to about 85k bytes
from my site, as N869_txt.bz2.
 
S

santosh

CBFalconer said:
Which doesn't have a greppable (etc.) text version, which N869
does. In fact you can get N869.txt compressed to about 85k bytes
from my site, as N869_txt.bz2.

You can convert n1256.pdf to a horrid, poorly formatted text file using
many easily available utilities which you can then "grep" to find the
relevant sections and go to them directly in the PDF file.

But personally I find that search has improved significantly on recent
versions of Adobe's PDF reader.
 
C

CBFalconer

santosh said:
You can convert n1256.pdf to a horrid, poorly formatted text file
using many easily available utilities which you can then "grep" to
find the relevant sections and go to them directly in the PDF file.

But personally I find that search has improved significantly on
recent versions of Adobe's PDF reader.

But, surprise, I can avoid all that nonsense by simply using the
pre-formatted and relatively compact N869.txt. It can be read with
less, searched with grep, etc. etc. etc. I don't even need any
monstrous oversized .pdf readers to access it. I can even cut and
paste.
 
M

Martin Ambuhl

CBFalconer said:
But, surprise, I can avoid all that nonsense by simply using the
pre-formatted and relatively compact N869.txt. It can be read with
less, searched with grep, etc. etc. etc. I don't even need any
monstrous oversized .pdf readers to access it. I can even cut and
paste.

<ot>
You might find the not-monstrous-oversized ghostview a reasonable choice
for reading .pdf files. Not only is the footprint much smaller, but
files load much faster.
</ot>
 
C

CBFalconer

Martin said:
<ot>
You might find the not-monstrous-oversized ghostview a reasonable
choice for reading .pdf files. Not only is the footprint much
smaller, but files load much faster.
</ot>

Is is smaller than more.com (mine)? or list, or less. Can it be
searched with grep.

more.com Oct 18 1988 435
list.com Jan 22 2004 28211
less.exe Apr 5 2002 204800
grep.exe Aug 12 2007 84240
 
R

Randy Howard

Is is smaller than more.com (mine)? or list, or less. Can it be
searched with grep.

more.com Oct 18 1988 435
list.com Jan 22 2004 28211
less.exe Apr 5 2002 204800
grep.exe Aug 12 2007 84240

Sure an old fart like yourself can afford a system by now with more
than 1MB of RAM. :p
 
M

Martin Ambuhl

CBFalconer said:
Is is smaller than more.com (mine)? or list, or less. Can it be
searched with grep.

I never made any statement to which that is an appropriate response.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top