On Wed, 06 Jan 2021 00:14:31 +0000, Charlie Gibbs wrote:
> On 2021-01-05, Martin Gregorie wrote:
>
>> On Tue, 05 Jan 2021 14:06:57 -0700, Peter Flass wrote:
>>
>>> You shouldn’t need declarations in C unless you’re using one of those
>>> new-fangled compilers that requires them. Old code should still be
>>> supported, though.
>>
>> Last time I tried it, (about 2 months ago), the current GNU C compiler
>> accepts the old K&R C first edition procedure declaration syntax. I
>> wish more compilers worked this way.
>
> I write functions this way:
>
> #ifdef PROTOTYPE char *foo(char *bar, int baz)
> #else char *foo(bar, baz) char *bar; int baz;
> #endif
>
> One #define in a header file adapts it to any old or new compiler.
> It works for declarations too.
That's safe but not necessary, for GNU C anyway.
The GNU C compiler series maintains backward compatibility to the year
dot. Dunno about other brands of C compiler, though. Just as well since I
have some sources that were written under OS/9 v2.4, so use the syntax
defined in the original K&R edition and I hate having to edit a source
file just because a new compiler version dropped support for everything
except the latest syntax.
Thats one reason I don't like Python.
COBOL is another language that historically tended to support only the
latest syntax, which is a pain since source files can be huge. I've
worked on COBOL program modules that ran to over 5000 lines back in the
day, i.e before 1978, when COBOL didn't yet support writing separately
compiled subroutines (no LINKAGE SECTION), though AFAIK COBOL has always
supported calling subroutines written in other languages).
--
--
Martin | martin at
Gregorie | gregorie dot org
--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)
|