Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Is this program standard conform?

Reply
Thread Tools

Is this program standard conform?

 
 
Fumeur
Guest
Posts: n/a
 
      01-21-2008
Is the following program standard conform?
(reduced as much as possible so it still shows the problem)

/* begin */
#include <stdio.h>

void xfprintf(FILE *);

void xfprintf(FILE *f) {
fprintf(f, "x\n");
}

int main(void) {
xfprintf(stderr);
return 0;
}
/* end */


It compiles with gcc without warnings and works correctly, but trying
to compile it with a particular other popular compiler, it yields the
following diagnostics:

lc -ansic -A -shadows -unused -O -c xfprintf.c -o xfprintf.obj
Error xfprintf.c: 4 redefinition of 'xfprintf'
Error c:\lcc\include\stdio.h: 116 Previous definition of 'xfprintf' here
2 errors, 0 warnings
1 error
make: *** [xfprintf.obj] Error 1

Who is at fault here, my program or the compiler?

 
Reply With Quote
 
 
 
 
vippstar@gmail.com
Guest
Posts: n/a
 
      01-21-2008
On Jan 21, 3:13 am, Fumeur <f...@invalid.invalid> wrote:
> Is the following program standard conform?
> (reduced as much as possible so it still shows the problem)
>
> /* begin */
> #include <stdio.h>
>
> void xfprintf(FILE *);
>
> void xfprintf(FILE *f) {
> fprintf(f, "x\n");
>
> }
>
> int main(void) {
> xfprintf(stderr);
> return 0;}
>
> /* end */
>
> It compiles with gcc without warnings and works correctly, but trying
> to compile it with a particular other popular compiler, it yields the
> following diagnostics:
>
> lc -ansic -A -shadows -unused -O -c xfprintf.c -o xfprintf.obj
> Error xfprintf.c: 4 redefinition of 'xfprintf'
> Error c:\lcc\include\stdio.h: 116 Previous definition of 'xfprintf' here
> 2 errors, 0 warnings
> 1 error
> make: *** [xfprintf.obj] Error 1
>
> Who is at fault here, my program or the compiler?


int foo(void); is a declaration while int foo(void) { return 42; } is
a definition.
Apparently, xfprintf() is defined twice.
Your snippet is valid ISO C.
 
Reply With Quote
 
 
 
 
Richard Tobin
Guest
Posts: n/a
 
      01-21-2008
In article <>, Fumeur <> wrote:

>lc -ansic -A -shadows -unused -O -c xfprintf.c -o xfprintf.obj
>Error xfprintf.c: 4 redefinition of 'xfprintf'
>Error c:\lcc\include\stdio.h: 116 Previous definition of 'xfprintf' here


Please don't feed the anonymous troll.

-- Richard
--
:wq
 
Reply With Quote
 
CBFalconer
Guest
Posts: n/a
 
      01-21-2008
Richard Tobin wrote:
> Fumeur <> wrote:
>
>> lc -ansic -A -shadows -unused -O -c xfprintf.c -o xfprintf.obj
>> Error xfprintf.c: 4 redefinition of 'xfprintf'
>> Error c:\lcc\include\stdio.h: 116
>> Previous definition of 'xfprintf' here

>
> Please don't feed the anonymous troll.


Why do you consider Fumeur to be a troll?

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.



--
Posted via a free Usenet account from http://www.teranews.com

 
Reply With Quote
 
Richard
Guest
Posts: n/a
 
      01-21-2008
(Richard Tobin) writes:

> In article <>, Fumeur <> wrote:
>
>>lc -ansic -A -shadows -unused -O -c xfprintf.c -o xfprintf.obj
>>Error xfprintf.c: 4 redefinition of 'xfprintf'
>>Error c:\lcc\include\stdio.h: 116 Previous definition of 'xfprintf' here

>
> Please don't feed the anonymous troll.
>
> -- Richard


But you can?
 
Reply With Quote
 
Richard Bos
Guest
Posts: n/a
 
      01-21-2008
Fumeur <> wrote:

> lc -ansic -A -shadows -unused -O -c xfprintf.c -o xfprintf.obj
> Error xfprintf.c: 4 redefinition of 'xfprintf'
> Error c:\lcc\include\stdio.h: 116 Previous definition of 'xfprintf' here
> 2 errors, 0 warnings
> 1 error
> make: *** [xfprintf.obj] Error 1


Either you're not calling your implementation correctly, or (in this
case, _highly_ more likely), it is broken. No ISO C implementation is
allowed to declare an identifier called xfprintf in its Standard headers
(which include <stdio.h>); it is in your namespace, not its, and it is
not an existing Standard C function.

Richard
 
Reply With Quote
 
Kenny McCormack
Guest
Posts: n/a
 
      01-21-2008
In article <3p8e65->,
Richard <> wrote:
> (Richard Tobin) writes:
>
>> In article <>, Fumeur <> wrote:
>>
>>>lc -ansic -A -shadows -unused -O -c xfprintf.c -o xfprintf.obj
>>>Error xfprintf.c: 4 redefinition of 'xfprintf'
>>>Error c:\lcc\include\stdio.h: 116 Previous definition of 'xfprintf' here

>>
>> Please don't feed the anonymous troll.
>>
>> -- Richard

>
>But you can?


Ssssh. You're using logic. Stop that. They don't like it.

 
Reply With Quote
 
jacob navia
Guest
Posts: n/a
 
      01-21-2008
Fumeur wrote:
> Is the following program standard conform?
> (reduced as much as possible so it still shows the problem)
>
> /* begin */
> #include <stdio.h>
>
> void xfprintf(FILE *);
>
> void xfprintf(FILE *f) {
> fprintf(f, "x\n");
> }
>
> int main(void) {
> xfprintf(stderr);
> return 0;
> }
> /* end */
>
>
> It compiles with gcc without warnings and works correctly, but trying
> to compile it with a particular other popular compiler, it yields the
> following diagnostics:
>
> lc -ansic -A -shadows -unused -O -c xfprintf.c -o xfprintf.obj
> Error xfprintf.c: 4 redefinition of 'xfprintf'
> Error c:\lcc\include\stdio.h: 116 Previous definition of 'xfprintf' here
> 2 errors, 0 warnings
> 1 error
> make: *** [xfprintf.obj] Error 1
>
> Who is at fault here, my program or the compiler?
>


You are using a bad bad compiler. This is unacceptable!

I would ask

1) For a full refund of the money you spent.

*After* you get the money

2) Ask Ossama bin laden to kill that infidel to the principles
and spirit of C.




--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
 
Reply With Quote
 
Mark Bluemel
Guest
Posts: n/a
 
      01-21-2008
jacob navia wrote:

> I would ask


> 2) Ask Ossama bin laden to kill that infidel to the principles
> and spirit of C.



I've found a simpler approach. Jacob goes into the killfile.
 
Reply With Quote
 
Fumeur
Guest
Posts: n/a
 
      01-21-2008
On Mon, 21 Jan 2008 11:10:47 GMT, Richard Bos wrote:

>Fumeur <> wrote:
>
>> lc -ansic -A -shadows -unused -O -c xfprintf.c -o xfprintf.obj
>> Error xfprintf.c: 4 redefinition of 'xfprintf'
>> Error c:\lcc\include\stdio.h: 116 Previous definition of 'xfprintf' here
>> 2 errors, 0 warnings
>> 1 error
>> make: *** [xfprintf.obj] Error 1

>
>Either you're not calling your implementation correctly, or (in this
>case, _highly_ more likely), it is broken. No ISO C implementation is
>allowed to declare an identifier called xfprintf in its Standard headers
>(which include <stdio.h>); it is in your namespace, not its, and it is
>not an existing Standard C function.


Thanks, that's what I thought. I had a look at the standard myself and
didn't find any reference to xfprintf(), but that was only C99 and not
any previous versions.

In the compiler/implementation's defense, it does not really "define"
said function at the indicated location, even though the diagnostic may
be misleading; line 116 in its <stdio.h> actually reads

int xfprintf(FILE *,const char *,...);


Would that warrant a bug report (rejects a conforming program)?

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What are the standard network functions provided in standard C? disappearedng@gmail.com C Programming 5 06-10-2008 08:57 PM
add pexpect to the standard library, standard "install" mechanism. funkyj Python 5 01-20-2006 08:35 PM
C program is standard C++ program? strutsng@gmail.com C Programming 50 10-30-2005 10:28 PM
C program is standard C++ program? strutsng@gmail.com C++ 50 10-30-2005 10:28 PM
How standard is the standard library? steve.leach Python 1 04-18-2005 04:07 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57