Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

C function overloading?

32 views
Skip to first unread message

JaSeong Ju

unread,
May 30, 2004, 8:48:23 PM5/30/04
to
I would like to overload a C function. Is there any easy way to do this?

Martien Verbruggen

unread,
May 30, 2004, 9:19:13 PM5/30/04
to
On Mon, 31 May 2004 09:48:23 +0900,
JaSeong Ju <j_kk...@yahoo.com> wrote:
>
>
> I would like to overload a C function. Is there any easy way to do this?

No.

Martien
--
|
Martien Verbruggen | Begin at the beginning and go on till you
| come to the end; then stop.
|

Ben Pfaff

unread,
May 30, 2004, 9:29:23 PM5/30/04
to
JaSeong Ju <j_kk...@yahoo.com> writes:

> I would like to overload a C function. Is there any easy way to do this?

No. C does not support function overloading.
--
"When I have to rely on inadequacy, I prefer it to be my own."
--Richard Heathfield

Mabden

unread,
May 30, 2004, 9:43:59 PM5/30/04
to
"Ben Pfaff" <b...@cs.stanford.edu> wrote in message
news:87d64lq...@blp.benpfaff.org...

You could, however, write a wrapper function that calls the normal C
function, but adds new functionality. Many people do this in calling memory
functions, for instance.

--
Mabden

E. Robert Tisdale

unread,
May 30, 2004, 9:13:02 PM5/30/04
to
JaSeong Ju wrote:

> I would like to overload a C function.
> Is there any easy way to do this?

Just compile with a C++ compiler.

Ben Pfaff

unread,
May 30, 2004, 10:11:18 PM5/30/04
to
"Mabden" <mab...@sbcglobal.net> writes:

> "Ben Pfaff" <b...@cs.stanford.edu> wrote in message
> news:87d64lq...@blp.benpfaff.org...
>> JaSeong Ju <j_kk...@yahoo.com> writes:
>>
>> > I would like to overload a C function. Is there any easy way to do
> this?
>>
>> No. C does not support function overloading.
>

> You could, however, write a wrapper function that calls the normal C
> function, but adds new functionality. Many people do this in calling memory
> functions, for instance.

Do you know what function overloading is? It is not changing the
behavior of some particular function, i.e. as a wrapper would,
which seems to be your implication.
--
"I should killfile you where you stand, worthless human." --Kaz

jacob navia

unread,
May 31, 2004, 12:14:54 AM5/31/04
to

"JaSeong Ju" <j_kk...@yahoo.com> a écrit dans le message de
news:c9dtcc$21r$1...@news.kreonet.re.kr...

> I would like to overload a C function. Is there any easy way to do this?

lcc-win32 is a compiler that supports function overloading.

http://www.cs.virginia.edu/~lcc-win32

It is not a C++ compiler


Ben Pfaff

unread,
May 31, 2004, 12:34:22 AM5/31/04
to
"jacob navia" <ja...@jacob.remcomp.fr> writes:

> "JaSeong Ju" <j_kk...@yahoo.com> a écrit dans le message de
> news:c9dtcc$21r$1...@news.kreonet.re.kr...
>> I would like to overload a C function. Is there any easy way to do this?
>
> lcc-win32 is a compiler that supports function overloading.
>

> It is not a C++ compiler

If it supports function overloading then it isn't a C compiler
either.
--
"IMO, Perl is an excellent language to break your teeth on"
--Micah Cowan

Mabden

unread,
May 31, 2004, 2:24:42 AM5/31/04
to
"Ben Pfaff" <b...@cs.stanford.edu> wrote in message
news:877jutq...@blp.benpfaff.org...

> "Mabden" <mab...@sbcglobal.net> writes:
>
> > "Ben Pfaff" <b...@cs.stanford.edu> wrote in message
> > news:87d64lq...@blp.benpfaff.org...
> >> JaSeong Ju <j_kk...@yahoo.com> writes:
> >>
> >> > I would like to overload a C function. Is there any easy way to do
> > this?
> >>
> >> No. C does not support function overloading.
> >
> > You could, however, write a wrapper function that calls the normal C
> > function, but adds new functionality. Many people do this in calling
memory
> > functions, for instance.
>
> Do you know what function overloading is?

What a nasty question. Of course I do. Do YOU know what a C forum is for?
Idiot.

--
Mabden


Stephen Sprunk

unread,
May 31, 2004, 3:25:37 AM5/31/04
to
"JaSeong Ju" <j_kk...@yahoo.com> wrote in message
news:c9dtcc$21r$1...@news.kreonet.re.kr...

> I would like to overload a C function. Is there any easy way to do this?

Standard C does not allow true function overloading, such as in C++.

However, you may be able to simulate the effect with macros; examine
<tgmath.h> for ideas how. Note that the method used by <tgmath.h> is
necessarily implementation-dependent, so don't expect your code to be
portable.

S

--
Stephen Sprunk "Stupid people surround themselves with smart
CCIE #3723 people. Smart people surround themselves with
K5SSS smart people who disagree with them." --Aaron Sorkin

Martin Dickopp

unread,
May 31, 2004, 4:35:40 AM5/31/04
to
"Mabden" <mab...@sbcglobal.net> writes:

> "Ben Pfaff" <b...@cs.stanford.edu> wrote in message
> news:877jutq...@blp.benpfaff.org...
>> "Mabden" <mab...@sbcglobal.net> writes:
>>
>> > "Ben Pfaff" <b...@cs.stanford.edu> wrote in message
>> > news:87d64lq...@blp.benpfaff.org...
>> >> JaSeong Ju <j_kk...@yahoo.com> writes:
>> >>
>> >> > I would like to overload a C function. Is there any easy way to
>> >> > do this?
>> >>
>> >> No. C does not support function overloading.
>> >
>> > You could, however, write a wrapper function that calls the normal
>> > C function, but adds new functionality. Many people do this in
>> > calling memory functions, for instance.
>>
>> Do you know what function overloading is?
>
> What a nasty question. Of course I do.

Then please explain how a wrapper function and/or adding new
functionality helps to solve the OP's problem.

> Idiot.

An ad hominem attack on a regular is reliable way to get into
everybody's killfile. Soon, you might feel very lonely here.

Martin


--
,--. Martin Dickopp, Dresden, Germany ,= ,-_-. =.
/ ,- ) http://www.zero-based.org/ ((_/)o o(\_))
\ `-' `-'(. .)`-'
`-. Debian, a variant of the GNU operating system. \_/

Christian Bau

unread,
May 31, 2004, 5:24:54 AM5/31/04
to
In article <c9dtcc$21r$1...@news.kreonet.re.kr>,
JaSeong Ju <j_kk...@yahoo.com> wrote:

> I would like to overload a C function. Is there any easy way to do this?

There is no way in C at all.

But what do you actually want to achieve? If you would post "I would
like to overload a C function because..." then maybe you can get help to
achieve what you want to achieve, without overloading a C function.

Peter Nilsson

unread,
May 31, 2004, 7:30:48 AM5/31/04
to
"Ben Pfaff" <b...@cs.stanford.edu> wrote in message news:873c5hq...@blp.benpfaff.org...

> "jacob navia" <ja...@jacob.remcomp.fr> writes:
> > "JaSeong Ju" <j_kk...@yahoo.com> a écrit dans le message de
> > news:c9dtcc$21r$1...@news.kreonet.re.kr...
> >> I would like to overload a C function. Is there any easy way to do this?
> >
> > lcc-win32 is a compiler that supports function overloading.
> >
> > It is not a C++ compiler
>
> If it supports function overloading then it isn't a C compiler
> either.

Why?! [Yes, I know Jacob's lcc was raised, but speaking more generally...]

Function overloading would require additional constraints on conforming programs using
that extension (e.g. C++ requires function prototypes), but I don't see how support for
function overloading would necessarily preclude implementation conformance.

--
Peter


Emmanuel Delahaye

unread,
May 31, 2004, 8:27:31 AM5/31/04
to
In 'comp.lang.c', "Mabden" <mab...@sbcglobal.net> wrote:

> You could, however, write a wrapper function that calls the normal C
> function, but adds new functionality. Many people do this in calling memory
> functions, for instance.

He he!

http://mapage.noos.fr/emdel/clib.htm module SYSALLOC

--
-ed- get my email here: http://marreduspam.com/ad672570
The C-language FAQ: http://www.eskimo.com/~scs/C-faq/top.html
C-reference: http://www.dinkumware.com/manuals/reader.aspx?lib=c99
FAQ de f.c.l.c : http://www.isty-info.uvsq.fr/~rumeau/fclc/

Peter Nilsson

unread,
May 31, 2004, 7:35:47 AM5/31/04
to
"JaSeong Ju" <j_kk...@yahoo.com> wrote in message news:c9dtcc$21r$1...@news.kreonet.re.kr...
> I would like to overload a C function. Is there any easy way to do this?

Only the old fashioned way...

void my_function_int(int);
void my_function_double(double);

...or by using judicious macros.

Neither is as passe as some might have you think.

As others have said, before you go rushing off to C++, perhaps you might like to explain
if you're trying to do something specific. [And if so, what?]

--
Peter


jacob navia

unread,
May 31, 2004, 8:34:06 AM5/31/04
to

"Peter Nilsson" <ai...@acay.com.au> a écrit dans le message de
news:40bb...@news.rivernet.com.au...

> Why?! [Yes, I know Jacob's lcc was raised, but speaking more generally...]
>
> Function overloading would require additional constraints on conforming
programs using
> that extension (e.g. C++ requires function prototypes), but I don't see
how support for
> function overloading would necessarily preclude implementation
conformance.
>

I have taken care (and we discussed here in this group about it) to keep
lcc-win32
100% compatible with the current ANSI standard.

The syntax proposed is:

int overloaded fn(Type1 arg1);

int overloaded fn(Type2 arg1);

When the compiler sees the construction:
fn(Type1) it will call the first one,
fn(Type2) it will call the second one.
else
"Undefined call to overloaded function line 45"

If the compiler sees:
int fn(Type1 arg1);

and LATER
int overloaded fn(Type23);

it will emit an error "function redefinition"

In all cases "overloaded" is NOT a keyword:

int overladed = 1;

will *still work* as expected.

CBFalconer

unread,
May 31, 2004, 8:41:37 AM5/31/04
to
Mabden wrote:
> "Ben Pfaff" <b...@cs.stanford.edu> wrote in message
>> "Mabden" <mab...@sbcglobal.net> writes:
>>> "Ben Pfaff" <b...@cs.stanford.edu> wrote in message
>>>> JaSeong Ju <j_kk...@yahoo.com> writes:
>>>>
>>>>> I would like to overload a C function. Is there any easy way
>>>>> to do this?
>>>>
>>>> No. C does not support function overloading.
>>>
>>> You could, however, write a wrapper function that calls the
>>> normal C function, but adds new functionality. Many people do
>>> this in calling memory functions, for instance.
>>
>> Do you know what function overloading is?
>
> What a nasty question. Of course I do.

It would not appear so.

> Do YOU know what a C forum is for? Idiot.

It is not a place for attacks on those more knowledgeable than
you, who happen to point out your ignorance. It will take little
of this to get yourself ignored.

--
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?

Joe Wright

unread,
May 31, 2004, 9:19:35 AM5/31/04
to

Alright, impress me. What is meant by function overloading? Even
though C does not support it, please show how to write a wrapper to
do so.

Is 'idiot' a term of endearment to you? If not, it is probably more
applicable to you than it is to Ben Pfaff.

--
Joe Wright mailto:joeww...@comcast.net
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---

Mario Charest

unread,
May 31, 2004, 10:43:47 AM5/31/04
to

"JaSeong Ju" <j_kk...@yahoo.com> wrote in message
news:c9dtcc$21r$1...@news.kreonet.re.kr...
> I would like to overload a C function. Is there any easy way to do this?
>

Not at the C level I think, but you can do it at the linker level. With
clever ordering of linking library you can replace pretty much any standard
libray call. Of course this is a hack, not portable and depends on linker
behavior. Furthermore; If you try to replace memcpy for example, it may not
work cause some compiler use inline code for memcpy and alike. Using this
solution is risky.

Christian Bau

unread,
May 31, 2004, 1:29:02 PM5/31/04
to
In article <40bb...@news.rivernet.com.au>,
"Peter Nilsson" <ai...@acay.com.au> wrote:

If I understand it correctly, the compiler would have to tell you the
first time it encounters something that is not pure Standard C, and then
it can go on doing whatever it likes. So if you write code by mistake
that is not Standard C but would be legal if function overloading were
part of C, then the compiler MUST tell you. But it can allow function
overloading after that.

E. Robert Tisdale

unread,
May 31, 2004, 1:52:44 PM5/31/04
to
Mabden wrote:

> Ben Pfaff wrote:


>
>>JaSeong Ju writes:
>>
>>>I would like to overload a C function. Is there any easy way to do this?
>
>>No. C does not support function overloading.
>>--
>>"When I have to rely on inadequacy, I prefer it to be my own."
>
> You could, however, write a wrapper function
> that calls the normal C function, but adds new functionality.
> Many people do this in calling memory functions, for instance.

I think that you have just described function *overriding*.
JaSeong Ju may have meant
function overriding instead of function overloading.

Keith Thompson

unread,
May 31, 2004, 2:47:05 PM5/31/04
to
"Mabden" <mab...@sbcglobal.net> writes:
> "Ben Pfaff" <b...@cs.stanford.edu> wrote in message
> news:87d64lq...@blp.benpfaff.org...
> > JaSeong Ju <j_kk...@yahoo.com> writes:
> > > I would like to overload a C function. Is there any easy way to
> > > do this?
> >
> > No. C does not support function overloading.
>
> You could, however, write a wrapper function that calls the normal C
> function, but adds new functionality. Many people do this in calling memory
> functions, for instance.

Yes, you certainly could, but I fail to see how this addresses the
OP's question.

A wrapper provides a new function, with a new name, that extends the
functionality of an existing function. Overloading provides two or
more functions with the same name.

Would you care to clarify what you meant?

--
Keith Thompson (The_Other_Keith) ks...@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.

Jack Klein

unread,
May 31, 2004, 4:14:46 PM5/31/04
to
On Sun, 30 May 2004 21:34:22 -0700, Ben Pfaff <b...@cs.stanford.edu>
wrote in comp.lang.c:

> "jacob navia" <ja...@jacob.remcomp.fr> writes:
>
> > "JaSeong Ju" <j_kk...@yahoo.com> a écrit dans le message de
> > news:c9dtcc$21r$1...@news.kreonet.re.kr...
> >> I would like to overload a C function. Is there any easy way to do this?
> >
> > lcc-win32 is a compiler that supports function overloading.
> >
> > It is not a C++ compiler
>
> If it supports function overloading then it isn't a C compiler
> either.

It would have been better perhaps if Jacob had stated: "lcc-win32 is a
compiler that supports function overloading as an extension", but I
think your reaction is a little overboard.

If a compiler supported signed and unsigned long long types or a
built-in Boolean type five years ago, it wasn't a strictly conforming
C compiler either, at least not when operated in a mode where these
things existed.

One of the most practical ways to propose the addition of features to
new generations of a language like C is not only to propose them, but
to show an existing implementation. Then the pros and cons become
directly testable and not merely theoretical.

Whether or not you or I think function overloading is something that
should be added to C is irrelevant.

At least compiler vendor has implemented <tgmath.h> functionality by
temporarily switching their implementation into C++ "mode" while
processing the header, which in their version contains ordinary C++
overloaded functions. At the end of the header it switches back to C
"mode", but the processed prototypes remain in the symbol table. The
proper overloaded function is called based on the types of the
arguments in the C source.

In fact, providing these as special case overloaded functions if
probably the simplest way to implement <tgmath.h> functionality in C,
and is of course perfectly legal for an implementation to do so.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html

Keith Thompson

unread,
May 31, 2004, 5:42:46 PM5/31/04
to
"E. Robert Tisdale" <E.Robert...@jpl.nasa.gov> writes:
> Mabden wrote:
> > Ben Pfaff wrote:
> >>JaSeong Ju writes:
> >>>I would like to overload a C function. Is there any easy way to do this?
> >
> >>No. C does not support function overloading.
> > You could, however, write a wrapper function that calls the normal C
> > function, but adds new functionality.
> > Many people do this in calling memory functions, for instance.
>
> I think that you have just described function *overriding*.
> JaSeong Ju may have meant
> function overriding instead of function overloading.

But overriding usually (I think) means providing a new function with
the same name. C doesn't support that either.

Mark McIntyre

unread,
May 31, 2004, 6:11:39 PM5/31/04
to
On Mon, 31 May 2004 21:30:48 +1000, in comp.lang.c , "Peter Nilsson"
<ai...@acay.com.au> wrote:

>"Ben Pfaff" <b...@cs.stanford.edu> wrote in message news:873c5hq...@blp.benpfaff.org...
>> "jacob navia" <ja...@jacob.remcomp.fr> writes:
>> > "JaSeong Ju" <j_kk...@yahoo.com> a écrit dans le message de
>> > news:c9dtcc$21r$1...@news.kreonet.re.kr...
>> >> I would like to overload a C function. Is there any easy way to do this?
>> >
>> > lcc-win32 is a compiler that supports function overloading.
>> >
>> > It is not a C++ compiler
>>
>> If it supports function overloading then it isn't a C compiler
>> either.
>
>Why?! [Yes, I know Jacob's lcc was raised, but speaking more generally...]

Because of 6.9(2) I think
"There shall be no more than one external definition for each identifier
declared with internal linkage in a translation unit. Moreover, if an
identifier declared with internal linkage is used in an expression (other
than as a part of the operand of a sizeof operator whose result is an
integer constant), there shall be exactly one external definition for the
identifier in the translation unit."

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>


----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---


----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---

Christian Bau

unread,
Jun 1, 2004, 3:16:10 AM6/1/04
to
In article <e5bnb0tgd3jur7njd...@4ax.com>,
Mark McIntyre <markmc...@spamcop.net> wrote:

> On Mon, 31 May 2004 21:30:48 +1000, in comp.lang.c , "Peter Nilsson"
> <ai...@acay.com.au> wrote:
>
> >"Ben Pfaff" <b...@cs.stanford.edu> wrote in message
> >news:873c5hq...@blp.benpfaff.org...
> >> "jacob navia" <ja...@jacob.remcomp.fr> writes:
> >> > "JaSeong Ju" <j_kk...@yahoo.com> a écrit dans le message de
> >> > news:c9dtcc$21r$1...@news.kreonet.re.kr...
> >> >> I would like to overload a C function. Is there any easy way to do
> >> >> this?
> >> >
> >> > lcc-win32 is a compiler that supports function overloading.
> >> >
> >> > It is not a C++ compiler
> >>
> >> If it supports function overloading then it isn't a C compiler
> >> either.
> >
> >Why?! [Yes, I know Jacob's lcc was raised, but speaking more generally...]
>
> Because of 6.9(2) I think
> "There shall be no more than one external definition for each identifier
> declared with internal linkage in a translation unit. Moreover, if an
> identifier declared with internal linkage is used in an expression (other
> than as a part of the operand of a sizeof operator whose result is an
> integer constant), there shall be exactly one external definition for the
> identifier in the translation unit."


Which means any program using function overloading would invoke
undefined behavior according to the C Standard (that is what the _shall_
means). An implementation is free to define the behavior in this case.

So your program is definitely not a C program, but a C compiler may
still accept it; some error messages may be required.

Stephen Sprunk

unread,
Jun 1, 2004, 3:53:53 AM6/1/04
to
"Christian Bau" <christ...@cbau.freeserve.co.uk> wrote in message
news:christian.bau-058...@slb-newsm1.svr.pol.co.uk...

> If I understand it correctly, the compiler would have to tell you the
> first time it encounters something that is not pure Standard C, and then
> it can go on doing whatever it likes. So if you write code by mistake
> that is not Standard C but would be legal if function overloading were
> part of C, then the compiler MUST tell you. But it can allow function
> overloading after that.

Non-conforming compilers are free to accept non-conforming code without
generating errors. The compilers I've worked with (gcc, icc, msvc) are not
strictly conforming in their default mode, but at least one of them can be
invoked as such if desired.

Function overloading is unusual because it requires breaking the ABI for a
given platform; most compiler extensions I've used only involve
non-conforming source, not broken binaries.

Mark McIntyre

unread,
Jun 1, 2004, 4:22:19 PM6/1/04
to
On Tue, 01 Jun 2004 08:16:10 +0100, in comp.lang.c , Christian Bau
<christ...@cbau.freeserve.co.uk> wrote:

>Which means any program using function overloading would invoke
>undefined behavior according to the C Standard (that is what the _shall_
>means). An implementation is free to define the behavior in this case.
>
>So your program is definitely not a C program, but a C compiler may
>still accept it; some error messages may be required.

Provided "some... may" means "at least one ... must"

A conforming compiler is free to accept anything at all, provided it
produces at least one diagnostic. It could accept the Grays Anatomy, or the
WEB source for Pascal, either before or after being tangled or woven.

If it does something with it other than produce the diagnostic, its not a
ISO C compiler, its something else.

Mark McIntyre

unread,
Jun 1, 2004, 4:23:24 PM6/1/04
to
On Tue, 01 Jun 2004 07:53:53 GMT, in comp.lang.c , "Stephen Sprunk"
<ste...@sprunk.org> wrote:

>"Christian Bau" <christ...@cbau.freeserve.co.uk> wrote in message
>news:christian.bau-058...@slb-newsm1.svr.pol.co.uk...
>> If I understand it correctly, the compiler would have to tell you the
>> first time it encounters something that is not pure Standard C, and then
>> it can go on doing whatever it likes.

Yup.

>Non-conforming compilers are free to accept non-conforming code without
>generating errors.

Meaningless statement. Non-conforming compilers are free to set fire to
your hair and paint your toenails green too.

Message has been deleted

jacob navia

unread,
Jun 1, 2004, 5:13:57 PM6/1/04
to

"Mark McIntyre" <markmc...@spamcop.net> a écrit dans le message de
news:s1ppb0lpnm8deohqp...@4ax.com...

>
> If it does something with it other than produce the diagnostic, its not a
> ISO C compiler, its something else.

lcc-win32 (when invoked without the -ansic flag) is not just an ISO C
compiler.

It will provide you with a shorthand notation where you give
a common name to a set of related routines.

This is nothing really new, and many languages provide this facility.

Instead of writing

int fn_int(int a);
int fn_long_double(long double a);
int fn_foo(foo a);

AD NAUSEUM

you have to remember only ONE name. Easy with the neuron's
random access memory. It shouldn't be wasted storing trivial
facts like zig different names for each variant of the same routine.

Of course this isn't in ISO C 89. But in 99, the C standard accepted
the "principle" that this construct *is* useful and provided a
SINGLE sqrt function without you having to remember 3 names for
each different function.

#include <tgmath.h>

I am confident that the 2009 edition will make the next logical
step and provide this for everybody according to the principle:

"If the implementor needs a certain feature the user needs it too".

Mark McIntyre

unread,
Jun 1, 2004, 5:45:06 PM6/1/04
to
On Tue, 1 Jun 2004 23:13:57 +0200, in comp.lang.c , "jacob navia"
<ja...@jacob.remcomp.fr> wrote:

>I am confident that the 2009 edition will make the next logical
>step and provide this for everybody according to the principle:
>
>"If the implementor needs a certain feature the user needs it too".

Frankly, and don't take offense, thats a ludicrous principle. The
implementor of a steel hulled ship needs a rivet gun. Passengers on the
boat don't.

jacob navia

unread,
Jun 1, 2004, 5:59:01 PM6/1/04
to

"Mark McIntyre" <markmc...@spamcop.net> a écrit dans le message de
news:l3upb0d5mk414dgk1...@4ax.com...

>
> Frankly, and don't take offense, thats a ludicrous principle. The
> implementor of a steel hulled ship needs a rivet gun. Passengers on the
> boat don't.

This doesn't hold. Users of compilers are building software, as the
compiler implementor is doing. Passangers aren't building ships.

Users of C programs do not need overloading of functions, agreed.

But users of C compilers do, since they are in exactly the same
business as the compiler implementor: they are building software.

Gordon Burditt

unread,
Jun 1, 2004, 5:56:05 PM6/1/04
to
>> A conforming compiler is free to accept anything at all, provided it
>> produces at least one diagnostic. It could accept the Grays Anatomy, or the
>> WEB source for Pascal, either before or after being tangled or woven.
>>
>> If it does something with it other than produce the diagnostic, it's not
>> a[n] ISO C compiler, it's something else.
>
> Not true. It might produce the diagnostic and *then* do something
>else, such as setting fire to your toenails; and still remain conforming.
>What it could *not* do would be to set fire to your toenails without
>first producing at least one diagnostic (such as "look out, your toenails
>are on fire").

Where in ANSI C does it say that the diagnostic must be produced
*FIRST*? Why couldn't the diagnostic be "your toes have burned
off", after you've arrived at the emergency room, or even after
you've gotten the bill?

It gets even messier when undefined behavior starts violating
temporal causality or invokes time travel. It gets even tricker
when undefined behavior retroactively alters the ANSI C standard.
For example, I think it was a "void main" program posted to comp.lang.c
that removed function concatenation from ANSI C.

(function concatenation: func = funccat(func1, func2) returns a
function pointer so that func(x) acts the same as func1(func2(x))
except that it calls private copies, not originals, of func1 and
func2 (meaning that any static or file-scope variables referenced
by func1 and func2 are not shared with the function called by func()
. The function pointer returned by funccat *MUST* be cast to void
TWICE and passed to free() before terminating the program).

>[Cf early (C90) versions of gcc, which according to legend
>would treat '#pragma' as a request to launch 'rogue'.

I believe I actually saw this one work.

Gordon L. Burditt

Richard Tobin

unread,
Jun 1, 2004, 6:08:07 PM6/1/04
to
In article <c9iu1l$1...@library1.airnews.net>,
Gordon Burditt <gordon...@burditt.org> wrote:

>>[Cf early (C90) versions of gcc, which according to legend
>>would treat '#pragma' as a request to launch 'rogue'.

>I believe I actually saw this one work.

The relevant source code is reproduced in

<1991Oct11....@thunder.mcrcim.mcgill.edu>

-- Richard

Keith Thompson

unread,
Jun 1, 2004, 9:23:44 PM6/1/04
to
Mark McIntyre <markmc...@spamcop.net> writes:
> On Tue, 01 Jun 2004 07:53:53 GMT, in comp.lang.c , "Stephen Sprunk"
> <ste...@sprunk.org> wrote:
[...]

> >Non-conforming compilers are free to accept non-conforming code without
> >generating errors.
>
> Meaningless statement. Non-conforming compilers are free to set fire to
> your hair and paint your toenails green too.

As far as I can tell, conforming compilers are equally free to set
fire to your hair and paint your toenails green.

CBFalconer

unread,
Jun 1, 2004, 10:16:01 PM6/1/04
to
jacob navia wrote:
>
... snip ...

>
> lcc-win32 (when invoked without the -ansic flag) is not just an
> ISO C compiler.
>
> It will provide you with a shorthand notation where you give
> a common name to a set of related routines.
>
> This is nothing really new, and many languages provide this
> facility.
>
> Instead of writing
>
> int fn_int(int a);
> int fn_long_double(long double a);
> int fn_foo(foo a);
>
> AD NAUSEUM
>
> you have to remember only ONE name. Easy with the neuron's
> random access memory. It shouldn't be wasted storing trivial
> facts like zig different names for each variant of the same
> routine.

All this is a way of further reducing the already poverty-stricken
internal checking and inherently minimal redundancy of C code,
thus leading to ever increasing density of programmer errors,
reduction of trust in software, and proliferation of subject
matter for the comp.risks newsgroup.

--
fix (vb.): 1. to paper over, obscure, hide from public view; 2.
to work around, in a way that produces unintended consequences
that are worse than the original problem. Usage: "Windows ME
fixes many of the shortcomings of Windows 98 SE". - Hutchison


Harti Brandt

unread,
Jun 2, 2004, 4:45:39 AM6/2/04
to
On Tue, 1 Jun 2004, jacob navia wrote:

jn>Instead of writing
jn>
jn>int fn_int(int a);
jn>int fn_long_double(long double a);
jn>int fn_foo(foo a);
jn>
jn>AD NAUSEUM
jn>
jn>you have to remember only ONE name. Easy with the neuron's
jn>random access memory. It shouldn't be wasted storing trivial
jn>facts like zig different names for each variant of the same routine.

One of the problem is that this makes programs harder to read if you
didn't write them. In C a line like

a = fn_int(b, c);

just requires you to lookup the definition for fn_int() to see what
happens. With overloading the line:

a = fn(b, c);

requires you to lookup the definition of b, c and a, lookup their types,
then to lookup fn() for the correct combination of types.

\begin{OT}
Even worse in C++ it requires you to lookup the inheritance
hierarchy for the types of b and c, all the possible candidate functions
that could be called here (taking into account type conversion
constructors), to remember the complex ruleset that directs the lookup of
the function and then to find out which functions really gets called here.
\end{OT}

Additionally there is, of course, no guarantee that fn(int, int) does more
or less the same as fn(long, int).

harti

jacob navia

unread,
Jun 2, 2004, 6:05:12 AM6/2/04
to

"Harti Brandt" <bra...@dlr.de> a écrit dans le message de
news:Pine.GSO.4.60.0406021037380.12298@zeus...

> \begin{OT}
> Even worse in C++ it requires you to lookup the inheritance
> hierarchy for the types of b and c, all the possible candidate functions
> that could be called here (taking into account type conversion
> constructors), to remember the complex ruleset that directs the lookup of
> the function and then to find out which functions really gets called here.
> \end{OT}
>

Since lcc-win32 is NOT a C++ compiler we are lucky: this doesn't apply here.


Mark McIntyre

unread,
Jun 2, 2004, 5:50:12 PM6/2/04
to
On Tue, 1 Jun 2004 23:59:01 +0200, in comp.lang.c , "jacob navia"
<ja...@jacob.remcomp.fr> wrote:

>
>"Mark McIntyre" <markmc...@spamcop.net> a écrit dans le message de
>news:l3upb0d5mk414dgk1...@4ax.com...
>>
>> Frankly, and don't take offense, thats a ludicrous principle. The
>> implementor of a steel hulled ship needs a rivet gun. Passengers on the
>> boat don't.
>
>This doesn't hold. Users of compilers are building software, as the
>compiler implementor is doing. Passangers aren't building ships.

Passengers are using the ship, just like I'm using the compiler. And just

>But users of C compilers do, since they are in exactly the same
>business as the compiler implementor: they are building software.

Frankly, if you want C++, you know where it is.

And BTW all this arguing just persuades me not to use your C compiler, I
could never trust it to do what its supposed to. I'd rather trust MS which
is a terrible indictment I reckon...

Mark McIntyre

unread,
Jun 2, 2004, 5:50:46 PM6/2/04
to
On Wed, 02 Jun 2004 01:23:44 GMT, in comp.lang.c , Keith Thompson
<ks...@mib.org> wrote:

>Mark McIntyre <markmc...@spamcop.net> writes:
>> On Tue, 01 Jun 2004 07:53:53 GMT, in comp.lang.c , "Stephen Sprunk"
>> <ste...@sprunk.org> wrote:
>[...]
>> >Non-conforming compilers are free to accept non-conforming code without
>> >generating errors.
>>
>> Meaningless statement. Non-conforming compilers are free to set fire to
>> your hair and paint your toenails green too.
>
>As far as I can tell, conforming compilers are equally free to set
>fire to your hair and paint your toenails green.

absolutely. Which renders Stephen's remark even more meaningless...

jacob navia

unread,
Jun 3, 2004, 2:52:07 AM6/3/04
to

"Mark McIntyre" <markmc...@spamcop.net> a écrit dans le message de
news:jkisb0pere8qmikdp...@4ax.com...

> On Tue, 1 Jun 2004 23:59:01 +0200, in comp.lang.c , "jacob navia"
> <ja...@jacob.remcomp.fr> wrote:
>
>
> And BTW all this arguing just persuades me not to use your C compiler, I
> could never trust it to do what its supposed to. I'd rather trust MS which
> is a terrible indictment I reckon...

Absolutely not.

Microsoft MSVC is a better compiler than what I can do myself.

It has better code generation, for starters, one of the fastest
code generators around, and a dedicated team of about thousand
people (peak).

If you see the C language as fixed, frozen and ready to go the
same path as the COBOL language you will find in MSVC the
compiler you want. The compiler is in the C89 stage and will
never incorporate anything new any more since Microsoft
has publicy stated that C99 will never be implemented.

In all respects, I think this is the compiler people like you
crave.

Ralmin

unread,
Jun 3, 2004, 8:42:59 AM6/3/04
to
"jacob navia" <ja...@jacob.remcomp.fr> wrote:
> Of course this isn't in ISO C 89. But in 99, the C standard
> accepted the "principle" that this construct *is* useful and provided a
> SINGLE sqrt function without you having to remember 3 names for
> each different function.

Six names, actually.

A glimpse from lcc-win32's <tgmath.h>?

...
double overload sqrt(double);
float overload sqrt(float);
long double overload sqrt(long double);
complex double overload sqrt(complex double);
complex float overload sqrt(complex float);
complex long double overload sqrt(complex long double);
...

--
Simon.


Mark McIntyre

unread,
Jun 3, 2004, 5:38:38 PM6/3/04
to
On Thu, 3 Jun 2004 08:52:07 +0200, in comp.lang.c , "jacob navia"
<ja...@jacob.remcomp.fr> wrote:

>If you see the C language as fixed, frozen and ready to go the
>same path as the COBOL language you will find in MSVC the
>compiler you want.

Thats not what I said at all. What I said was "if you need C++ you know
where to find it". I stand by that. If I want a language offering
polymorphism, function overloading, templates etc, I use C++. When I want
something lean and mean, I use C.

>The compiler is in the C89 stage and will
>never incorporate anything new any more since Microsoft
>has publicy stated that C99 will never be implemented.

MS also said that the internet had no future, and that Windows NT support
would cease in 2002. I seem to recall some slight change of tactics...

>In all respects, I think this is the compiler people like you
>crave.

You have no idea what I crave, but for what its worth, its not a compiler
and you can't get it in CLC.... :-)

Friedrich Dominicus

unread,
Jun 3, 2004, 11:25:13 PM6/3/04
to
Mark McIntyre <markmc...@spamcop.net> writes:

>
> Thats not what I said at all. What I said was "if you need C++ you know
> where to find it". I stand by that. If I want a language offering
> polymorphism, function overloading, templates etc, I use C++. When I want
> something lean and mean, I use C.

Having such things does not make a language fat.

Regards
Friedrich


--
Please remove just-for-news- to reply via e-mail.

Michael Wojcik

unread,
Jun 7, 2004, 9:37:26 PM6/7/04
to

In article <c9mhqq$p2h$1...@news-reader3.wanadoo.fr>, "jacob navia" <ja...@jacob.remcomp.fr> writes:
>
> If you see the C language as fixed, frozen and ready to go the
> same path as the COBOL language

What "path" is that? And what does it have to do with COBOL, which
is not "fixed" or "frozen", and in fact has a very active and
aggressive standardization process which has incorporated numerous
features in recent revisions, and continues to incorporate more?

C changes a lot more slowly than COBOL does. (This is not necessarily
an advantage either way.)

I suggest refraining from using COBOL as an example, if you're not
familiar with COBOL.

> you will find in MSVC the compiler you want.

Unlikely to be generally true. MSVC has poor diagnostics - too few
warnings at level 3 and too many at level 4. It suffers from odd
implementation problems, such as its collection of conflicting C
runtime libraries. It targets only a few platforms and operating
systems.

There are reasons to use MSVC, but it's not the absolute best choice
for everyone who's not interested in C99. That claim is simply silly.

--
Michael Wojcik michael...@microfocus.com

"We are facing a dire shortage of clowns," said Erickson, also known as
Jingles.

0 new messages