home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!uunet.ca!geac!censor!isgtec!robert
- From: robert@isgtec.com (Robert Osborne)
- Newsgroups: comp.lang.c
- Subject: Re: Macros for ANSI prototypes
- Message-ID: <3160@isgtec.isgtec.com>
- Date: 20 Aug 92 15:04:10 GMT
- References: <1992Aug18.170108.1827@druid.uucp>
- Sender: news@isgtec.com
- Lines: 89
-
- darcy@druid.uucp (D'Arcy J.M. Cain) writes:
- #robert@isgtec.com (Robert Osborne) writes:
- #>darcy@druid.uucp (D'Arcy J.M. Cain) writes:
- #>> [...] The K&R code just becomes one of the stages of the
- #>> compilation. [...]
- #>> ANSI C --> K&R C --> Assembler --> a.out
- #>> You see the K&R is simply an intermediate stage and is thrown out after
- #>> along with the .s and .o files.
- #>Gaak! This is gross.
- #>You can't throw away the K&R step because you need the source for
- #>debuggers.
- #
- #Who said you had to throw it away immediately? In fact the example I use
- #later involved copying the K&R code to another box and compiling there. By
- #"after" I meant "after it is no longer needed." I kind of thought that was
- #obvious.
-
- Well since the K&R code is always needed while the .s and .o are not
- this wasn't that 'obvious'.
-
- #>The K&R systems are used also for development; there are enough
- #>problems with the compilers and with the speed of compile without
- #>adding yet another preprocessing step.
- #>
- #>It would only take one major bug introduced by the ANSI to K&R
- #>step to remove the developer time savings.
- #
- #If your tools don't work then get ones that do. I mean if we are going
- #to discuss the use of various tools we have to assume that cpp does macro
- #processing by the accepted rules, cc compiles C code and all the other
- #tools perform as advertised. I don't think it matters where a major bug
- #is introduced. If a tool is broken it will cost the developer time.
- #Just ask anyone who does development using compilers from you-know-who
- #with a version number of x.0.
-
- Get a grip. I was just saying the cost of the added complexity of a
- extra preprocessing step has to be weighed against the cost of not
- using it. If the minor difficulties caused by cpp were not grossly
- overwhelmed by being able to conditionally compile and #include files
- would you use it? If the development ease/speed gains from using C
- didn't overwhelm the power of assembler would you use C?
-
- #>I do not consider this even remotely as elegant as the prototype macros.
- #
- #My way:
- #
- #int foo(char *, int);
- #...
- #int foo(char *bar, int n)
- #{
- # /* stuff */
- #}
- #
- #Your way: (I don't have the original message but I think this is close)
- #
- #int foo(__DECL((char *, int));
- #...
- #int foo __DEFN((char *bar __ int n))
- #{
- # /* stuff */
- #}
-
- I agree the original method, not mine, suggested was very (VERY!) ugly.
- I don't use the ANSI style for function arguments so...
- My way:
-
- --- in some include ---
- #ifdef HAS_PROTOTYPES
- #define PROTO(s) s
- #else
- #define PROTO(s) ()
- #endif
-
- --- in junk.c ---
- int foo PROTO((char *, int));
-
- int foo(bar, n)
- char *bar;
- int n;
- {
- }
-
- Since prototypes are generated by a tool (mkptypes in our case)
- this is easier and more elegant (in my mind and that in those of
- the rest of our group) than either of the above methods.
-
- Rob.
- --
- Robert A. Osborne ...!uunet.ca!isgtec!robert or robert@isgtec.com
-