variadic functions

F

Frank

In Dread Ink, the Grave Hand of Stephen Sprunk Did Inscribe:
[ My apologies for the flood of delayed responses; my old news server
was silently eating all my posts for the last week or so.]
I don't know what happens here during compilation or execution.

I meant with stdio.h included. It draws errors from my
implementation:


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int printf(const char *, ...); /* line 5 */ [snip]
int printf(char * r, ...) /* line 23 */ [snip]
Wedit output window build: Sat Oct 03 11:56:39 2009
Error c:\lcc\source\nick2.c: 23 redefinition of 'printf'
Error c:\lcc\source\nick2.c: 5 Previous definition of 'printf' here

Your compiler is buggy; line 5 does not define printf() -- it merely
declares it.

That's not a bug; it's a feature. When I want to say
declaration/definition, I get it wrong more than fifty percent of the time.
My sense was that there was only one definition, and that two different
defintions is not standard C. I'll know more about this when Plauger's
book shows up.
However, what I suspect your compiler meant to complain about is that
the argument types of those two lines do not agree; one has a (const
char *) and the other has a (char *).

How about when you throw restrict and format in there?
#include'ing <stdio.h> and then providing your own declaration of
printf() is a Bad Idea(tm). The point of #include'ing headers is so
that you don't _need_ to write those declarations -- which you may get
wrong.

#include'ing <stdio.h> and then providing your own definition of
printf() is also a Bad Idea(tm). If you don't want to use the standard
library's printf() and will provide your own function with that name, do
not #include <stdio.h> -- and expect anyone else who sees your code to
be confused and/or think you're an idiot.

No one local to me seems to think I'm an idiot.
--
Frank

During the Reagan Administration, Bob Dole was present at a ceremony that
included each living ex-president. Looking at a tableau of Ford, Carter and
Nixon, Dole said, 'There they are: Hear No Evil, See No Evil and Evil.'
~~ Al Franken,
 
S

Stephen Sprunk

Frank said:
In Dread Ink, the Grave Hand of Stephen Sprunk Did Inscribe:
Frank said:
I don't know what happens here during compilation or execution.

I meant with stdio.h included. It draws errors from my
implementation:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int printf(const char *, ...); /* line 5 */ [snip]
int printf(char * r, ...) /* line 23 */ [snip]
Wedit output window build: Sat Oct 03 11:56:39 2009
Error c:\lcc\source\nick2.c: 23 redefinition of 'printf'
Error c:\lcc\source\nick2.c: 5 Previous definition of 'printf' here

Your compiler is buggy; line 5 does not define printf() -- it merely
declares it.

That's not a bug; it's a feature.

Humor aside, no. It's a bug.
When I want to say declaration/definition, I get it wrong more than
fifty percent of the time.

If you can't get the terms right, that's somewhat understandable; it
took me quite a bit of reading clc before I truly understood the
distinction (especially when you throw the word "prototype" in...).

A compiler author not being able to get the terms right is another
matter; if they can't even get the Standard's terminology right, how can
they possibly produce an implementation that conforms to that Standard?
My sense was that there was only one definition, and that two different
defintions is not standard C. I'll know more about this when Plauger's
book shows up.

Two (or more) definitions of a function, whether the same or different,
are not allowed.

Two (or more) declarations of a function are allowed as long as they all
agree.

A function definition also implicitly declares that function*, which
means that the definition on line 23 must agree with the declaration on
line 5, which in turn must agree with the declaration in <stdio.h>.

(* Probably not the right wording, but IMHO it's close enough for this
discussion.)
How about when you throw restrict and format in there?

I'm pretty sure the argument name is irrelevant, but I'm not sure about
a restrict modifier. const-ness definitely matters, at least when it
comes to pointer arguments.

I liken this to operator precedence: if you have to look it up, use
parentheses instead. If you can't remember what parts of a declaration
have to be the same, just make them all the same so you don't have to
worry about it (and neither will anyone else reading your code).

S
 
J

James Kuyper

Stephen Sprunk wrote:
....
A function definition also implicitly declares that function*, which
means that the definition on line 23 must agree with the declaration on
line 5, which in turn must agree with the declaration in <stdio.h>.

(* Probably not the right wording, but IMHO it's close enough for this
discussion.)

More precisely, the portion of a function definition that precedes the
function body is, itself, a function declaration.
 
F

Flash Gordon

It's interesting that "the usual suspects" who are normally so quick to
pounce on newbies for exceeding the 4-line signature "limit" have been
eerily silent about Stephen's ridiculous recent 49-line exercises in
paranoia.

As so often, it's one rule for them and another rule for everyone else.

I agree it's ridiculous, but I didn't see it because my news reader hid
it for me.

Stephen,

It is ridiculous adding that size of signature. With the forgeries that
have happened here, I can understand a desire to sign your messages, but
that really is going a LONG way over the top!
 
K

Kenny McCormack

Antoninus Twink said:
It's interesting that "the usual suspects" who are normally so quick to
pounce on newbies for exceeding the 4-line signature "limit" have been
eerily silent about Stephen's ridiculous recent 49-line exercises in
paranoia.
Yep.

As so often, it's one rule for them and another rule for everyone else.

Yep.
 
F

Flash Gordon

Richard said:
"The usual suspects" are, of course, Chuck Falconer. Why he has
stopped posting to the group, I don't know. But the fact that he has
stopped posting to the group may explain why he didn't complain about
the sig length.

I thought it included a few more than that. Of course, it could be that
everyone other than Chuck is a sock puppet of Chuck...
It is? (Views source.) Oh. Yeah, perhaps a bit. The normal guideline
is 4, and 50-odd does seem a bit in excess of that.

You don't need anything like that bis a signature to sign messages
securely, so yes it is.
Is it that huge a deal? 10 years ago, yes, okay. Maybe even five years
ago. But what proportion of Usenauts is on dialup nowadays?

I'm on a mobile phone connection because Broadband has not reached here
yet, so this the fastest I can get, and sometimes it is slow enough that
I get timeouts (at other times it is fast). I don't know how common slow
connections are though.
 
K

Keith Thompson

Richard Heathfield said:
Or that you are believing what you're told by trolls instead of
considering the matter objectively. Right now I can only think of
/one/ other regular contributor who /might/ have voiced objections to
over-long sigs in comp.lang.c in the last few years[1]. (I won't name
him, because I'm probably misremembering.) It's far rarer than you
seem to think.

I've done so a few times. (I don't intend to entertain the trolls by
discussing this any further.)

[...]
 
S

Stephen Sprunk

Antoninus said:
It's interesting that "the usual suspects" who are normally so quick to
pounce on newbies for exceeding the 4-line signature "limit" have been
eerily silent about Stephen's ridiculous recent 49-line exercises in
paranoia.

My .sig is only three lines. The S/MIME signature is in a separate body
part that, unless you're using a truly ancient newsreader, should be
hidden from view. The point of the 4-line .sig rule was to prevent
visual clutter, so a hidden body part cannot violate that rule.

As far as paranoia goes, with the recent spate of forgeries I deemed a
digital signature to be prudent. Perhaps the need has passed; I'll
consider turning it back off by default.

(If anyone can tell me how to get Tbird to make an S/MIME signature
smaller, without getting rid of it entirely, I'll gladly do so. My
apologies to Flash Gordon and other low-bandwidth users.)
As so often, it's one rule for them and another rule for everyone else.

Now that the issue has been pointed out and they've complained about it,
are you happy? Did that make your world a better place, or were you
just looking for an excuse to take a potshot at others and try to bring
them down to your level?

S
 
S

Seebs

My .sig is only three lines. The S/MIME signature is in a separate body
part that, unless you're using a truly ancient newsreader, should be
hidden from view. The point of the 4-line .sig rule was to prevent
visual clutter, so a hidden body part cannot violate that rule.

slrn is not all that ancient. :)

-s
 
F

Flash Gordon

Stephen Sprunk wrote:

As far as paranoia goes, with the recent spate of forgeries I deemed a
digital signature to be prudent. Perhaps the need has passed; I'll
consider turning it back off by default.

(If anyone can tell me how to get Tbird to make an S/MIME signature
smaller, without getting rid of it entirely, I'll gladly do so.

I think all you need to do is use a certificate with fewer bits. I'm
guessing you are using a 1024 bit certificate, and I would have thought
256 or even 128 bits would be sufficient for Usenet postings.
My
apologies to Flash Gordon and other low-bandwidth users.)

Hey, it happens.
Now that the issue has been pointed out and they've complained about it,
are you happy? Did that make your world a better place, or were you
just looking for an excuse to take a potshot at others and try to bring
them down to your level?

Well, I just think you've gone far too big on it.
 
S

Stephen Sprunk

Flash said:
I think all you need to do is use a certificate with fewer bits. I'm
guessing you are using a 1024 bit certificate, and I would have thought
256 or even 128 bits would be sufficient for Usenet postings.

For better or worse, 2048-bit certs are what the well-known CAs are
issuing today, and there's no option to tell them to go smaller. The
root of the problem is that Tbird (and many other clients, I suspect)
includes the entire sender cert in every message, with no option to send
just the signature as many PGP users do.

I've turned off signing by default for my news account, though, so you
shouldn't have to deal with it anymore unless you correspond with me via
email or we have another rash of forgeries here.

S
 
A

Antoninus Twink

As far as paranoia goes, with the recent spate of forgeries I deemed a
digital signature to be prudent. Perhaps the need has passed; I'll
consider turning it back off by default.

I wouldn't presume to speak for HfC, but it seems pretty clear to me
that you're one of the good guys in this group and so should have
nothing to fear from forgeries.

Despite the hysterical propaganda put out by the "regulars", I think I'm
right in saying that every single one of the forgeries was targeted at
someone who had been guilty of repeated unprovoked attacks on Han, and
repeteadly disrupted the newsgroup by passive-aggressive behavior.
Now that the issue has been pointed out and they've complained about
it, are you happy? Did that make your world a better place, or were
you just looking for an excuse to take a potshot at others and try to
bring them down to your level?

I agree that pointing out the hypocrisy and double-standards of the
"regulars" is largely a futile exercise that's unlikely ever to have any
positive effect: Their minds are closed. Still, sometimes it's nice to
be able to express one's frustration about it.
 
F

Frank

In Dread Ink, the Grave Hand of James Kuyper Did Inscribe:
Stephen Sprunk wrote:
...

More precisely, the portion of a function definition that precedes the
function body is, itself, a function declaration.

I'll have to think about this.

James, any word about water on the moon?
--
Frank

There's no liberal echo chamber in this country. There's a right-wing echo
chamber. I want to create a countervailing echo chamber.
~~ Al Franken, Chicago Tribune interview, on
 
F

Frank

In Dread Ink, the Grave Hand of Richard Heathfield Did Inscribe:

[1] I specifically exclude complaints made to CBF about /his/
overly-long sig. That was really just hypocrisy exposure. (Yes, I
know - we're all hypocrites.)

I'm not a hypocrite. I don't tell others what to do. Whatever happened to
Chuck? Did he finally give up his post as clc management?
--
Frank

Most of us here in the media are what I call infotainers...Rush Limbaugh is
what I call a disinfotainer. He entertains by spreading disinformation.
~~ Al Franken
 
F

Frank

In Dread Ink, the Grave Hand of Antoninus Twink Did Inscribe:
Maybe there's no internet access at the hospice.

I guess no one can elude the ultimate bitbucket.
--
Frank

There's no liberal echo chamber in this country. There's a right-wing echo
chamber. I want to create a countervailing echo chamber.
~~ Al Franken, Chicago Tribune interview, on
 
C

chad

"The usual suspects" are, of course, Chuck Falconer. Why he has
stopped posting to the group, I don't know. But the fact that he has
stopped posting to the group may explain why he didn't complain about
the sig length.



It is? (Views source.) Oh. Yeah, perhaps a bit. The normal guideline
is 4, and 50-odd does seem a bit in excess of that.


Is it that huge a deal? 10 years ago, yes, okay. Maybe even five years
ago. But what proportion of Usenauts is on dialup nowadays?

I still use a US Robotics 56k external dial up modem for my internet
connection at home.
 

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

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top