Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!mcvax!inria!axis!philip From: philip@axis.UUCP (Philip Peake) Newsgroups: comp.lang.c Subject: Re: Questions on X3J11 draft Message-ID: <775@axis.UUCP> Date: Sun, 7-Dec-86 06:03:19 EST Article-I.D.: axis.775 Posted: Sun Dec 7 06:03:19 1986 Date-Received: Mon, 8-Dec-86 02:11:27 EST References: <351@danews.ATT.COM> <7373@utzoo.UUCP> <3800@watmath.UUCP> Reply-To: philip@axis.UUCP (Philip Peake) Organization: Axis Digital, 135 rue d'Aguesseau, Boulogne, 92100, FRANCE Lines: 47 Keywords: C,X3J11 In article <3800@watmath.UUCP> rbutterworth@watmath.UUCP writes: > >I can think of a perfectly conforming ANSI compiler that will break >almost any existing C code. Imagine a piece of code such as the following: > #include > { > extern int getchar(); > auto int c; > c=getchar(); >At the moment, this will blow up on (all?) existing C compilers since >"getchar" is a macro. Of course everyone KNOWS this and so never puts >such things into their code. But under ANSI, almost any function can >be defined as a macro in the header files. That means that almost >any program that contains an "extern type libCfunc();" in it can >potentially break under a conforming ANSI compiler. > >This change may or may not be a good thing; I don't know. >I do know that my own coding style has changed drastically >because of it. I used to put explicit extern statements for >all the functions I use, simply to document the fact that I >am using them. Now I NEVER put extern statements into ANY >source.c file. This is a *very* good point ! (Why didn't I think of it ? ......) My personal coding style has changed considerably over the years, and one of the directions in which it evolved was to ALWAYS put extern declarations of any functions that I use. I started by putting them into a header file, this gets to be a pain, since we either have a header file for each C file, or lots of redundant extern declarations, and 'make' going beserk if you change one of the declarations. I now put them into the C file - I think its cleaner, and I like to be able to find the type of a function when I am looking at a piece of code. Taking the above example (sligthly modified), what if the function actually returns something other than int ? You HAVE to put the extern definition, if not other things will probably (certainly ?) break. How can I know, when trying to write portable code, if the 'library' function I am going to use is a real function or a macro ? Philip