Page 1 of 1

terminate command in C source (solved)

Posted: Mon Jul 25, 2022 7:39 am
by cobaka

Hello all:

I'm learning C. In the code fragment below (I got from ... probably source forge) my (gcc) compiler does not like the 'terminate' function.

Code: Select all

assemble()      // ***************************** def.
{
    initpass();
    while ( !endfile ) {
        if ( getline() == NULL ) {
            fclose(srcf);
            if ( (srcf = popfile()) == NULL ) break;
                  continue;
                                 }
        initline();
        if ( *lineptr == '*' ) clearaddress();
        else {
            if ( !isspace(*lineptr) ) deflabel();
            operation();
             }
        putline();
                       }
    terminate();  //   <<-------------terminate --------------<<
}

I cannot find any reference to 'terminate' in the GNU gcc manual or the GNU library function manual.
I searched /usr/lib for ' terminate('. Appears as a python function - not obvious as a C funtion.
The code above comes from around 1986 and is probably C at the K&R standard.
Does any-one here know about 'terminate' and is there a standard function (even return or break) that might replace this word?

Error message is: as68.c:243:5: warning: implicit declaration of function ‘terminate’; did you mean ‘tempnam’? [-Wimplicit-function-declaration]
terminate();
^~~~~~~~~
tempnam

Suggestions?

cobaka


Re: terminate command in C source

Posted: Mon Jul 25, 2022 4:31 pm
by Burunduk

The function declaration is missing. It should appear before the first function call. You've said the code is old. It may rely on implicit declarations. The program will probably work if the int terminate() is defined somewhere in its source files. Though it's possible, it's a bad example to learn from. The recent standards disallow implicit declarations.

This assembler is a maintained project. I've compiled it in Fossapup64 in a second without any warnings. It has produced a binary from a sample code but without an emulator I can't test it.


Re: terminate command in C source

Posted: Tue Jul 26, 2022 12:52 am
by wiak
cobaka wrote: Mon Jul 25, 2022 7:39 am

Hello all:

I'm learning C. In the code fragment below (I got from ... probably source forge) my (gcc) compiler does not like the 'terminate' function.

Code: Select all

assemble()      // ***************************** def.
{
 ...
    terminate();  //   <<-------------terminate --------------<<
}

assemble() is a function and it is calling another function called terminate(), but you'd need to show whole program to see where and if the function terminate() is defined somewhere. If it is a simple program with just one piece of source code it will be at the top somewhere. Otherwise it might be being brought in via an #include <file> statement.