*BSD News Article 17107


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!munnari.oz.au!bruce.cs.monash.edu.au!monu6!escargot!minyos.xx.rmit.OZ.AU!rxklam
From: rxklam@minyos.xx.rmit.OZ.AU (Luke Mewburn)
Newsgroups: comp.os.386bsd.bugs
Subject: stdio.h & __sputc problems with gcc -ansi
Date: 14 Jun 1993 09:19:57 GMT
Organization: Even More NetBSD Hackers Inc, RMIT div.
Lines: 49
Message-ID: <1vhfrt$p3p@escargot.xx.rmit.OZ.AU>
Reply-To: zak@rmit.edu.au
NNTP-Posting-Host: minyos.xx.rmit.oz.au


I've discovered an annoying problem in <stdio.h> when running
gcc (1.40 or whatever's the default) with -ansi, and a project with
multiple .o files.

When gcc gets around to linking, I get "multiply defined __sputc"
errors (I can't remember the exact text, this is from memory).
Looking in stdio.h, I see that __sputc is defined as 
	static __inline
if __GNUC__ and __STDC__ defined (i.e, gcc with -ansi.)
Well, I can't see the problem, and there are times when I would really
like to do `-ansi -pedantic' on a project.

Got any ideas?

Here's the relevant code from stdio.h btw:


-- file: include/stdio.h --
    /*
     * The __sfoo macros are here so that we can 
     * define function versions in the C library.
     */
    #if defined(__GNUC__) && defined(__STDC__)
    static __inline int __sputc(int _c, FILE *_p) {
	    if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n'))
		    return (*_p->_p++ = _c);
	    else
		    return (__swbuf(_c, _p));
    }
    #else
    /*
     * This has been tuned to generate reasonable code on the vax using pcc.
     */
    #define	__sputc(c, p) \
	    (--(p)->_w < 0 ? \
		    (p)->_w >= (p)->_lbfsize ? \
			    (*(p)->_p = (c)), *(p)->_p != '\n' ? \
				    (int)*(p)->_p++ : \
				    __swbuf('\n', p) : \
			    __swbuf((int)(c), p) : \
		    (*(p)->_p = (c), (int)*(p)->_p++))
    #endif
-- end file --


--
Luke Mewburn [Zak], <zak@rmit.edu.au>
"Lawyers - the only group for which ignorance of the law is not a crime" - anon