The latest gcc compiler is 14.2, or something like that.
I have used prior versions 11.2 and 12.2 which allow C code that does
not always type routines, such as int main()
Since the original compiler, it was understood that the default for a
routine is type int, so that a compiler would accept
main()
and, although it might give a nuisance warning the program would compile
and run.
The latest gcc seems to require every routine to be typed. As of the
current time, I have 1,046,000 lines of C code written over the last 45
years or so, and much of it was written according to K&R.
Does anyone know of a compiler add-on which will read existing code, and insert type (int) when the routine is not explicitly given?
Thanks.
On Fri, 7 Feb 2025 03:19:58 -0000 (UTC), root wrote:
The latest gcc seems to require every routine to be typed. As of the
current time, I have 1,046,000 lines of C code written over the last 45
years or so, and much of it was written according to K&R.
Jeopardy question: “What is Technical Debt?”
You can probably get the code to compile with the proper "--std="
directive to gcc.
The latest gcc seems to require every routine to be typed. As of the
current time, I have 1,046,000 lines of C code written over the last 45
years or so, and much of it was written according to K&R.
Does anyone know of a compiler add-on which will
read existing code, and insert type (int) when
the routine is not explicitly given?
root <[email protected]> writes:
Does anyone know of a compiler add-on which will
read existing code, and insert type (int) when
the routine is not explicitly given?
No add-on needed, just have a look at the manual, specifically:
https://gcc.gnu.org/onlinedocs/gcc-14.1.0/gcc/Standards.html#C-Language
vallor <[email protected]> wrote:
I tried std=gnu89, but that didn't fix the problem.
You can probably get the code to compile with the proper "--std="
directive to gcc.
A really strange thing: one of my old programs had a list of routines at
the front, with entries like:
int main ();
void this();
etc.
when the compiler encountered the line
int main(argc,argv)
it threw up an error.
You can probably get the code to compile with the
proper "--std=" directive to gcc.
Richard Kettlewell <[email protected]d> wrote:
root <[email protected]> writes:
Does anyone know of a compiler add-on which will read existing code,
and insert type (int) when the routine is not explicitly given?
No add-on needed, just have a look at the manual, specifically:
https://gcc.gnu.org/onlinedocs/gcc-14.1.0/gcc/Standards.html#C-Language
Thanks Richard, but, also looking at the dialect link, what option
should I use to mimic gcc version 11.2.0 (GCC) or 12.2, either of
which compiles my stuff without a problem.
I have tried std=gnu89 but that didn't work. I tried other stuff of
the form -Wno-implicit-init or something like that that compiler
suggested but no change with that.
Post some example code, the exact command you used to compile it, and
the errors you go.
On 07/02/2025 17:35, root wrote:
when the compiler encountered the line
int main(argc,argv)
it threw up an error.
Well did you have
{
char *argv[]; int argc;
...underneath?
when the compiler encountered the line
int main(argc,argv)
it threw up an error.
int main(argc,argv)
char *argv[]; int argc;
On Fri, 07 Feb 2025 22:28:29 +0000, The Natural Philosopher wrote:
On 07/02/2025 17:35, root wrote:
when the compiler encountered the line
int main(argc,argv)
it threw up an error.
Well did you have
{
char *argv[]; int argc;
...underneath?
itym
char *argv[]; int argc;
{
as in
/* K&R C style function */
int main(argc,argv)
char *argv[]; int argc;
{
/*... */
return 0;
}
:-)
On 07/02/2025 17:35, root wrote:
when the compiler encountered the line
int main(argc,argv)
it threw up an error.
Well did you have
{
char *argv[]; int argc;
...underneath?
| Sysop: | Keyop |
|---|---|
| Location: | Huddersfield, West Yorkshire, UK |
| Users: | 715 |
| Nodes: | 16 (2 / 14) |
| Uptime: | 35:21:20 |
| Calls: | 12,109 |
| Files: | 15,006 |
| Messages: | 6,518,351 |