By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,411 Members | 1,045 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,411 IT Pros & Developers. It's quick & easy.

C function overloading?

P: n/a
I would like to overload a C function. Is there any easy way to do this?

Nov 14 '05 #1
Share this Question
Share on Google+
45 Replies


P: n/a
On Mon, 31 May 2004 09:48:23 +0900,
JaSeong Ju <j_******@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.
|

Nov 14 '05 #2

P: n/a
JaSeong Ju <j_******@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
Nov 14 '05 #3

P: n/a
"Ben Pfaff" <bl*@cs.stanford.edu> wrote in message
news:87************@blp.benpfaff.org...
JaSeong Ju <j_******@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."


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

Nov 14 '05 #4

P: n/a
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.
Nov 14 '05 #5

P: n/a
"Mabden" <ma****@sbcglobal.net> writes:
"Ben Pfaff" <bl*@cs.stanford.edu> wrote in message
news:87************@blp.benpfaff.org...
JaSeong Ju <j_******@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
Nov 14 '05 #6

P: n/a

"JaSeong Ju" <j_******@yahoo.com> a écrit dans le message de
news:c9**********@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
Nov 14 '05 #7

P: n/a
"jacob navia" <ja***@jacob.remcomp.fr> writes:
"JaSeong Ju" <j_******@yahoo.com> a écrit dans le message de
news:c9**********@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
Nov 14 '05 #8

P: n/a
"Ben Pfaff" <bl*@cs.stanford.edu> wrote in message
news:87************@blp.benpfaff.org...
"Mabden" <ma****@sbcglobal.net> writes:
"Ben Pfaff" <bl*@cs.stanford.edu> wrote in message
news:87************@blp.benpfaff.org...
JaSeong Ju <j_******@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
Nov 14 '05 #9

P: n/a
"JaSeong Ju" <j_******@yahoo.com> wrote in message
news:c9**********@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

Nov 14 '05 #10

P: n/a
"Mabden" <ma****@sbcglobal.net> writes:
"Ben Pfaff" <bl*@cs.stanford.edu> wrote in message
news:87************@blp.benpfaff.org...
"Mabden" <ma****@sbcglobal.net> writes:
> "Ben Pfaff" <bl*@cs.stanford.edu> wrote in message
> news:87************@blp.benpfaff.org...
>> JaSeong Ju <j_******@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. \_/
Nov 14 '05 #11

P: n/a
In article <c9**********@news.kreonet.re.kr>,
JaSeong Ju <j_******@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.
Nov 14 '05 #12

P: n/a
"Ben Pfaff" <bl*@cs.stanford.edu> wrote in message news:87************@blp.benpfaff.org...
"jacob navia" <ja***@jacob.remcomp.fr> writes:
"JaSeong Ju" <j_******@yahoo.com> a écrit dans le message de
news:c9**********@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
Nov 14 '05 #13

P: n/a
In 'comp.lang.c', "Mabden" <ma****@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/
Nov 14 '05 #14

P: n/a
"JaSeong Ju" <j_******@yahoo.com> wrote in message news:c9**********@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
Nov 14 '05 #15

P: n/a

"Peter Nilsson" <ai***@acay.com.au> a écrit dans le message de
news:40******@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.

Nov 14 '05 #16

P: n/a
Mabden wrote:
"Ben Pfaff" <bl*@cs.stanford.edu> wrote in message
"Mabden" <ma****@sbcglobal.net> writes:
"Ben Pfaff" <bl*@cs.stanford.edu> wrote in message
JaSeong Ju <j_******@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?

Nov 14 '05 #17

P: n/a
Mabden wrote:
"Ben Pfaff" <bl*@cs.stanford.edu> wrote in message
news:87************@blp.benpfaff.org...
"Mabden" <ma****@sbcglobal.net> writes:

"Ben Pfaff" <bl*@cs.stanford.edu> wrote in message
news:87************@blp.benpfaff.org...

JaSeong Ju <j_******@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.


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:jo********@comcast.net
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Nov 14 '05 #18

P: n/a

"JaSeong Ju" <j_******@yahoo.com> wrote in message
news:c9**********@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.

Nov 14 '05 #19

P: n/a
In article <40******@news.rivernet.com.au>,
"Peter Nilsson" <ai***@acay.com.au> wrote:
"Ben Pfaff" <bl*@cs.stanford.edu> wrote in message
news:87************@blp.benpfaff.org...
"jacob navia" <ja***@jacob.remcomp.fr> writes:
"JaSeong Ju" <j_******@yahoo.com> a écrit dans le message de
news:c9**********@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.


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.
Nov 14 '05 #20

P: n/a
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.
Nov 14 '05 #21

P: n/a
"Mabden" <ma****@sbcglobal.net> writes:
"Ben Pfaff" <bl*@cs.stanford.edu> wrote in message
news:87************@blp.benpfaff.org...
JaSeong Ju <j_******@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.
Nov 14 '05 #22

P: n/a
On Sun, 30 May 2004 21:34:22 -0700, Ben Pfaff <bl*@cs.stanford.edu>
wrote in comp.lang.c:
"jacob navia" <ja***@jacob.remcomp.fr> writes:
"JaSeong Ju" <j_******@yahoo.com> a écrit dans le message de
news:c9**********@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/~a...FAQ-acllc.html
Nov 14 '05 #23

P: n/a
"E. Robert Tisdale" <E.**************@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.

--
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.
Nov 14 '05 #24

P: n/a
On Mon, 31 May 2004 21:30:48 +1000, in comp.lang.c , "Peter Nilsson"
<ai***@acay.com.au> wrote:
"Ben Pfaff" <bl*@cs.stanford.edu> wrote in message news:87************@blp.benpfaff.org...
"jacob navia" <ja***@jacob.remcomp.fr> writes:
> "JaSeong Ju" <j_******@yahoo.com> a écrit dans le message de
> news:c9**********@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 =---
Nov 14 '05 #25

P: n/a
In article <e5********************************@4ax.com>,
Mark McIntyre <ma**********@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" <bl*@cs.stanford.edu> wrote in message
news:87************@blp.benpfaff.org...
"jacob navia" <ja***@jacob.remcomp.fr> writes:
> "JaSeong Ju" <j_******@yahoo.com> a écrit dans le message de
> news:c9**********@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.
Nov 14 '05 #26

P: n/a
"Christian Bau" <ch***********@cbau.freeserve.co.uk> wrote in message
news:ch*********************************@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.

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

Nov 14 '05 #27

P: n/a
On Tue, 01 Jun 2004 08:16:10 +0100, in comp.lang.c , Christian Bau
<ch***********@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
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 =---
Nov 14 '05 #28

P: n/a
On Tue, 01 Jun 2004 07:53:53 GMT, in comp.lang.c , "Stephen Sprunk"
<st*****@sprunk.org> wrote:
"Christian Bau" <ch***********@cbau.freeserve.co.uk> wrote in message
news:ch*********************************@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.

--
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 =---
Nov 14 '05 #29

P: n/a

On Tue, 1 Jun 2004, Mark McIntyre wrote:

On Tue, 01 Jun 2004 08:16:10 +0100, Christian Bau 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"


And provided "must be" means "is". ;-)
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"). [Cf early (C90) versions of gcc, which according to legend
would treat '#pragma' as a request to launch 'rogue'. Did that make gcc
non-conforming because ISO didn't mention 'rogue' in the Standard? No.
It merely made gcc perverse.]

IOW, getting back to the point that started this whole subthread
(AFAICT): Jacob's lcc-win32 compiler *may be* a conforming C compiler,
even though it incorporates non-ISO extensions, as long as it also
incorporates a standard C compiler. (Yet discussion of lcc-win32 is
just as off-topic here as is discussion of any other specific
implementation.)
Any *program* that takes advantage of lcc-win32's non-ISO extensions,
however, is most definitely not a standard C program --- and thus would
also be off-topic in this group.
Still, discussion of lcc-win32's conformance to the Standard, and the
cute features that make it conforming despite all its crazy extensions,
would IMHO be topical here. :)

-Arthur
Nov 14 '05 #30

P: n/a

"Mark McIntyre" <ma**********@spamcop.net> a écrit dans le message de
news:s1********************************@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".

Nov 14 '05 #31

P: n/a
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.
--
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 =---
Nov 14 '05 #32

P: n/a

"Mark McIntyre" <ma**********@spamcop.net> a écrit dans le message de
news:l3********************************@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.

Nov 14 '05 #33

P: n/a
>> 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
Nov 14 '05 #34

P: n/a
In article <c9********@library1.airnews.net>,
Gordon Burditt <go***********@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

<19*******************@thunder.mcrcim.mcgill.edu >

-- Richard
Nov 14 '05 #35

P: n/a
Mark McIntyre <ma**********@spamcop.net> writes:
On Tue, 01 Jun 2004 07:53:53 GMT, in comp.lang.c , "Stephen Sprunk"
<st*****@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.

--
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.
Nov 14 '05 #36

P: n/a
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
Nov 14 '05 #37

P: n/a
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
Nov 14 '05 #38

P: n/a

"Harti Brandt" <br****@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.
Nov 14 '05 #39

P: n/a
On Tue, 1 Jun 2004 23:59:01 +0200, in comp.lang.c , "jacob navia"
<ja***@jacob.remcomp.fr> wrote:

"Mark McIntyre" <ma**********@spamcop.net> a écrit dans le message de
news:l3********************************@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
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 =---
Nov 14 '05 #40

P: n/a
On Wed, 02 Jun 2004 01:23:44 GMT, in comp.lang.c , Keith Thompson
<ks***@mib.org> wrote:
Mark McIntyre <ma**********@spamcop.net> writes:
On Tue, 01 Jun 2004 07:53:53 GMT, in comp.lang.c , "Stephen Sprunk"
<st*****@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...

--
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 =---
Nov 14 '05 #41

P: n/a

"Mark McIntyre" <ma**********@spamcop.net> a écrit dans le message de
news:jk********************************@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.

Nov 14 '05 #42

P: n/a
"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.
Nov 14 '05 #43

P: n/a
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.... :-)

--
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 =---
Nov 14 '05 #44

P: n/a
Mark McIntyre <ma**********@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.
Nov 14 '05 #45

P: n/a

In article <c9**********@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 mi************@microfocus.com

"We are facing a dire shortage of clowns," said Erickson, also known as
Jingles.
Nov 14 '05 #46

This discussion thread is closed

Replies have been disabled for this discussion.