• Compiler utility

    From root@21:1/5 to All on Fri Feb 7 03:19:58 2025
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From vallor@21:1/5 to root on Fri Feb 7 04:11:02 2025
    On Fri, 7 Feb 2025 03:19:58 -0000 (UTC), root <[email protected]> wrote in <vo3u4t$37omt$[email protected]>:

    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.

    You can probably get the code to compile with the
    proper "--std=" directive to gcc.

    --
    -v System76 Thelio Mega v1.1 x86_64 NVIDIA RTX 3090 Ti
    OS: Linux 6.13.1 Release: Mint 22.1 Mem: 258G
    "If things get any worse, I'll have to ask you to stop helping me."

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From [email protected]@21:1/5 to Lawrence D'Oliveiro on Fri Feb 7 01:06:33 2025
    On 2/7/25 1:02 AM, Lawrence D'Oliveiro wrote:
    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?”

    Heh heh heh ... :-)

    Yep, The Background CAN change - and fucks up
    a LOT of What Came Before. Don't like it at all,
    but it's gonna happen anyway.

    A common example is the change from Python-2
    to Python-3. It's *almost* the same, but not
    *quite*.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From rbowman@21:1/5 to vallor on Fri Feb 7 06:05:09 2025
    On 7 Feb 2025 04:11:02 GMT, vallor wrote:

    You can probably get the code to compile with the proper "--std="
    directive to gcc.

    -fpermissive may work too. I had a similar problem with variables defined
    in header files. It was never a good idea but when you're dealing with 25
    years of legacy code. It required editing the makefiles but that was
    easier than sorting out the mess.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to root on Fri Feb 7 06:02:22 2025
    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?”

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richard Kettlewell@21:1/5 to root on Fri Feb 7 08:42:20 2025
    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

    --
    https://www.greenend.org.uk/rjk/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From root@21:1/5 to Richard Kettlewell on Fri Feb 7 17:49:16 2025
    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.

    It might be that gnu89 would compile my most really old stuff,
    but since then I have adapted to newer compilers that gnu89
    doesn't like. There are 1,354 .c files, and as I said, over
    1,045,000 lines of code. I am too old to fix them in my
    remaining lifetime.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From vallor@21:1/5 to root on Fri Feb 7 17:51:44 2025
    On Fri, 7 Feb 2025 17:35:43 -0000 (UTC), root <[email protected]> wrote in <vo5g9e$3jith$[email protected]>:

    vallor <[email protected]> wrote:

    You can probably get the code to compile with the proper "--std="
    directive to gcc.


    I tried std=gnu89, but that didn't fix the problem.

    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.

    Not sure what would be going on there.

    $ cat try.c
    #include <stdio.h>

    int main();
    void this();

    int main(argc,argv)
    int argc;
    char ** argv;
    {
    printf("%s\n","Does this work?");
    return 0;
    }

    $ make try
    cc "-std=gnu89" try.c -o try

    $ ./try
    Does this work?

    $ cat try2.c
    #include <stdio.h>

    int main();
    void this();

    int main(argc,argv)
    /*int argc;
    char ** argv;*/
    {
    printf("%s\n","Does this work?");
    return 0;
    }

    $ make try2
    cc "-std=gnu89" try2.c -o try2

    $ ./try2
    Does this work?

    $ gcc --version
    gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
    Copyright (C) 2023 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
    PURPOSE.

    --
    -v System76 Thelio Mega v1.1 x86_64 NVIDIA RTX 3090 Ti
    OS: Linux 6.13.1 Release: Mint 22.1 Mem: 258G
    "Come any closer and I'll use my magnet!"

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From root@21:1/5 to vallor on Fri Feb 7 17:35:43 2025
    vallor <[email protected]> wrote:

    You can probably get the code to compile with the
    proper "--std=" directive to gcc.


    I tried std=gnu89, but that didn't fix the problem.

    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richard Kettlewell@21:1/5 to root on Fri Feb 7 20:16:48 2025
    root <[email protected]> writes:
    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.

    There’s no option to mimic a different compiler version. The options
    select a language version.

    If you want the behavior of a specific compiler version then the usual
    approach is just to use that version.

    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.

    --
    https://www.greenend.org.uk/rjk/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From root@21:1/5 to Richard Kettlewell on Fri Feb 7 22:19:52 2025
    Richard Kettlewell <[email protected]d> wrote:

    Post some example code, the exact command you used to compile it, and
    the errors you go.


    Thanks for the offer Richard. I have moved beyond the problem.
    I have what I need with the 11.2.0 compiler and the 6.12.12 kernel.

    I think this will give an example of what I found:
    #include <stdio.h>
    #include <stdlib.h>
    #include <unistd.h>
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <fcntl.h>
    #include <termio.h>
    #include <sys/wait.h>
    #include <signal.h>
    #include <time.h>
    #include <sys/time.h>
    #include <string.h>
    #include <ctype.h>

    int main();

    //lots more code in here

    int main(argc,argv)
    int argc;
    char *argv[];
    {
    exit(0);
    }

    The command first command would have been
    simply gcc program.c -o program

    then I tried stuff like:

    gcc --std=gnu89 program.c -o program

    The actual program I looked at had used forward
    references and I put a large number of the
    declarations up front. The new compiler flagged
    the redefinitions as errors, not warnings as
    might have been done with a duplicate #define.

    I can't remember now what program it was, nor
    for what compiler I originally used that would
    have allowed the forward references.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lew Pitcher@21:1/5 to The Natural Philosopher on Fri Feb 7 22:44:32 2025
    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;
    }

    :-)

    --
    Lew Pitcher
    "In Skills We Trust"

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From The Natural Philosopher@21:1/5 to root on Fri Feb 7 22:28:29 2025
    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?
    --
    It’s easier to fool people than to convince them that they have been fooled. Mark Twain

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Lew Pitcher on Sat Feb 8 03:30:57 2025
    On Fri, 7 Feb 2025 22:44:32 -0000 (UTC), Lew Pitcher wrote:

    int main(argc,argv)
    char *argv[]; int argc;

    Ah, good old Algol-60-type syntax ...

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From The Natural Philosopher@21:1/5 to Lew Pitcher on Sat Feb 8 13:12:41 2025
    On 07/02/2025 22:44, Lew Pitcher wrote:
    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;
    }

    :-)

    Yup. I fully adopted the 'definitions inside the function brackets'
    years ago and forgotted (sic!) the exact syntax.

    --
    All political activity makes complete sense once the proposition that
    all government is basically a self-legalising protection racket, is
    fully understood.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From root@21:1/5 to The Natural Philosopher on Sun Feb 9 04:51:06 2025
    The Natural Philosopher <[email protected]d> 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?

    I put the argument definitions on separate lines
    after the function line.


    The complaint was for the int main().

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)