Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: howmany -- What the F**k ? |
| Date | 2015-11-18 08:25 -0800 |
| Organization | None to speak of |
| Message-ID | <lnr3jngtpu.fsf@kst-u.example.com> (permalink) |
| References | <XnsA556C180B2E15jamesdowallen@178.63.61.175> |
James Dow Allen <gmail@jamesdowallen.nospam> writes:
> I run gcc under cygwin and recently discovered something that [...]
> annoyed me a little.
>
> I named a function howmany(). [...]
>
> Of course I got a weird syntax error and immediately guessed what was
> wrong. I changed the function name to howmany_and_fuk_you_too(), and it
> worked. But I still took the time to track it down. Note that one can
> imagine situations where debugging would have been harder.
>
> sys/types.h has
> #define howmany(x,y) (((x)+((y)-1))/(y))
>
> The problem was caused by my including stdio.h, a header I barely use.
[...]
gcc is not a conforming C compiler by default. But even given that,
defining an identifier like `howmany` in a standard header is unwise at
best; I'd call it a bug.
> (Trying to play like the pedants, I even include stdlib.h -- a header
> which has absolutely no value to me except suppressing an inane warning
> about exit(). Perhaps I should stop including it before its zillions of
> garbage defines find a way of causing more trouble.)
<stdlib.h> is the header that declares the exit() funcion. That's not
an inane warning; it's telling you that you're calling an undeclared
function. It's *probably* not going to cause problems (if it compiles),
but it's probably assuming that exit returns int rather than void. My
advice: If you're going to call exit(), add the `#include <stdlib.h>`
(and then deal with any problems it might cause).
> So my questions are:
>
> (1) Do any of you ever use the RedHat/Whatever howmany() ?
> I often need that facility but ... gasp! ... invest several hundred
> milliseconds to type out the arithmetic myself. Or, gasp, write my own
> inane macros in my own inane header file using names and usages, gasp,
> convenient for me.
I had never heard of it.
> (2) Should such garbage be given reserved names like
> ___WHATEVER___howmany() ?
Yes.
> (I'm uninterested in details about "reserved names" -- I don't
> think "howmany" is reserved and that's what I'm talking about.)
That's a pity, because the details of which names are reserved are at
the heart of the problem you're having. You're right, "howmany" isn't
reserved, and an implementation shouldn't be making it visible in a way
that interferes with user code.
> Whatever genius defined howmany for me isn't the only problem.
> j0, j1, yn etc. have been shitcanned for decades as soon as you
> include math.h -- I guess the fear there was that bessel_j0()
> would be less descriptive than j0().
Normally if you compile with something like
gcc -std=cNN -pedantic
where NN is 89, 90, 99, or 11, it should avoid defining any non-reserved
identifiers. If it doesn't, that's a bug. (That goes for j0, j1, et al.)
I don't see the issue on my own system (Linux, gcc, glibc), but I seem
to recall running into something similar on Cygwin, which uses a
different library implementation. I have a Cygwin system at home; I'll
try to look into it in the next few days.
You can report the bug on one of the Cygwin mailing lists. I suggest
showing a minimal test case that defines `howmany`, along with the
result of compiling with `gcc -std=c99 -pedantic`.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
howmany -- What the F**k ? James Dow Allen <gmail@jamesdowallen.nospam> - 2015-11-18 12:01 +0000
Re: howmany -- What the F**k ? Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-11-18 07:52 -0500
Re: howmany -- What the F**k ? "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-18 05:14 -0800
Re: howmany -- What the F**k ? Keith Thompson <kst-u@mib.org> - 2015-11-18 08:26 -0800
Re: howmany -- What the F**k ? Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-11-18 11:44 -0500
Re: howmany -- What the F**k ? Keith Thompson <kst-u@mib.org> - 2015-11-18 09:08 -0800
Re: howmany -- What the F**k ? James Kuyper <jameskuyper@verizon.net> - 2015-11-18 08:31 -0500
Re: howmany -- What the F**k ? Keith Thompson <kst-u@mib.org> - 2015-11-18 08:25 -0800
Re: howmany -- What the F**k ? James Dow Allen <jdallen2000@yahoo.com> - 2015-11-18 11:58 -0800
Re: howmany -- What the F**k ? Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-11-18 15:14 -0500
Re: howmany -- What the F**k ? James Dow Allen <jdallen2000@yahoo.com> - 2015-11-18 17:48 -0800
Re: howmany -- What the F**k ? James Kuyper <jameskuyper@verizon.net> - 2015-11-18 21:06 -0500
Re: howmany -- What the F**k ? Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-11-19 08:23 -0500
Re: howmany -- What the F**k ? Keith Thompson <kst-u@mib.org> - 2015-11-19 21:45 -0800
Re: howmany -- What the F**k ? Tim Rentsch <txr@alumni.caltech.edu> - 2015-11-20 12:55 -0800
Re: howmany -- What the F**k ? Keith Thompson <kst-u@mib.org> - 2015-11-20 03:27 -0800
Re: howmany -- What the F**k ? Philip Lantz <prl@canterey.us> - 2015-11-21 20:40 -0800
Re: howmany -- What the F**k ? James Kuyper <jameskuyper@verizon.net> - 2015-11-22 10:09 -0500
Re: howmany -- What the F**k ? Philip Lantz <prl@canterey.us> - 2015-11-22 10:18 -0800
Re: howmany -- What the F**k ? gazelle@shell.xmission.com (Kenny McCormack) - 2015-11-22 18:35 +0000
Re: howmany -- What the F**k ? Philip Lantz <prl@canterey.us> - 2015-11-22 13:10 -0800
Re: howmany -- What the F**k ? James Kuyper <jameskuyper@verizon.net> - 2015-11-22 13:57 -0500
Re: howmany -- What the F**k ? Philip Lantz <prl@canterey.us> - 2015-11-22 13:02 -0800
Re: howmany -- What the F**k ? James Kuyper <jameskuyper@verizon.net> - 2015-11-22 16:15 -0500
Re: howmany -- What the F**k ? James Kuyper <jameskuyper@verizon.net> - 2015-11-23 06:33 -0500
Re: howmany -- What the F**k ? gazelle@shell.xmission.com (Kenny McCormack) - 2015-11-23 12:17 +0000
Re: howmany -- What the F**k ? Philip Lantz <prl@canterey.us> - 2015-11-23 21:09 -0800
Re: howmany -- What the F**k ? Keith Thompson <kst-u@mib.org> - 2015-11-22 12:34 -0800
Re: howmany -- What the F**k ? James Kuyper <jameskuyper@verizon.net> - 2015-11-22 16:18 -0500
csiph-web