This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: (printf) ("hello world\n");


Jan-Benedict Glaw <jbglaw@lug-owl.de> writes:

| On Thu, 2003-12-11 09:01:51 -0800, Geoff Keating <geoffk@geoffk.org>
| wrote in message <jmllpjxp8g.fsf@desire.geoffk.org>:
| > Segher Boessenkool <segher@kernel.crashing.org> writes:
| 
| > > That does not prevent you from declaring and defining your own
| > > printf() function (with a different prototype) though; it only requires
| > > that you make that function have external linkage.
| > 
| > You mean 'internal linkage'.  You can define your own function named
| > printf only if you (a) do not include stdio.h and (b) declare it
| > 'static'.
| 
| Um, I think:
| 	- You may include <stdio.h> as long as your new printf() has
| 	  compatible arguments. It's a Bad Thing, though, because
| 	  declaration in <stdio.h> doesn't really belong to your new
| 	  function.
| 	- You may also have your own function non-static. Then, it
| 	  depends on link-order which function (yours or libc's) is
| 	  used. Of course, that's horrible, too:)

If the printf function does not have an internal linkage, then it is
an undefined behaviour.  That rules out both points.

-- Gaby


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]