Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c Subject: Re: function declaration without args no longer works Date: Tue, 05 May 2026 10:03:53 -0700 Organization: A noiseless patient Spider Lines: 64 Message-ID: <86ecjpwzye.fsf@linuxsc.com> References: <10sl5na$5ov$1@reader1.panix.com> <10slehr$mho$1@reader1.panix.com> <10tasgg$7nu$1@reader1.panix.com> <86zf2ewcm8.fsf@linuxsc.com> <10tcc5j$e45$1@reader1.panix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Tue, 05 May 2026 17:03:56 +0000 (UTC) Injection-Info: dont-email.me; logging-data="615331"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19SzD++I9hSe+mNhbfCbHU9nSdDXLhD7QI="; posting-host="3e8439ee7a5eb7f921cc930c7b47e195" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:0VJReNRJ6LJxjUNqRS0PX3/Wpqs= sha1:knAUNMw4/A7gyxetrprX5qKsU04= sha256:Wb2Gt+pCeqRTed94XZFymhZk1cTGCAH+jIJBmBPjobQ= sha1:fVDn9QKJPj1/uwAwqZIYkIxvNno= Xref: csiph.com comp.lang.c:398381 John Forkosh writes: > Tim Rentsch wrote: > >> John Forkosh writes: >> >>> John Forkosh wrote: >>> >>>> Michael B?uerle wrote: >>>> >>>>> John Forkosh wrote: >>>>> >>>>> Have you tried "-std=c99" (or whatever standard >>>>> your code was written for)? >>>> >>>> Thanks, Michael. I've tried it now:) Indeed, as soon >>>> as I saw your "-std=" I vaguely recalled that switch. >>>> And, yeah, both -std=c99 and (as also suggested) >>>> -std=gnu17 ignore the problem, and compile just fine >>>> Thanks again. >>> >>> Update: While subsequently trying to compile some even older >>> code, written circa 1991, I had to go back even further, >>> to -std=c89 (or equivalently -ansi as per the man cc page). >>> And then, no errors, no warnings, not even with -pedantic. >> >> What were the sorts of things that caused diagnostics when >> compiled under -std=c99? > > Three errors (identical with or without -pedantic)... > > bash-5.3$ cc -DTESTDRIVE -DNOTMSDOS -std=c99 -pedantic -lm \ > treelib.c -o treelib > treelib.c: In function 'talloc': > treelib.c:205:11: error: implicit declaration of function 'tallchk' > [-Wimplicit-function-declaration] > 205 | if ( !tallchk() ) tree=(double *)NULL; /* set error if corrupt */ > | ^~~~~~~ > treelib.c: At top level: > treelib.c:1986:1: error: return type defaults to 'int' [-Wimplicit-int] > 1986 | main ( argc, argv ) > | ^~~~ > treelib.c: In function 'main': > treelib.c:2149:29: error: implicit declaration of function 'close'; > did you mean 'fclose'? [-Wimplicit-function-declaration] > 2149 | if ( fp != (FILE *)NULL ) close(fp); /* close output file */ > | ^~~~~ > | fclose > > ... at line 205, I indeed used tallchk() without declaring it > within the talloc() function where it's used. > at line 1986, I indeed wrote main() instead of int main(). > at line 2149, I indeed meant fclose(). > [...] None of these problems is difficult to remedy. Is that also true for the diagnostics you see for other sources? Or are some of them harder to correct? Do you have a breakdown of all the types of flagged constructs in all of the source files (i.e., those that you mention in a later posting)? It would be interesting to know how many bugs would be turned up (e.g., like the close()/fclose() confusion) by compiling with C99 rather than C89/C90.