Reputation: 1
I'm absolutely not a coder, but I'm trying to get a very old program to compile from fortran to C, so that I can play a game i've not played in 20+ years (originally created on HP3000 in the late 70s!) on my linux box.
Someone has written a make.sh file, using f2c (fortran to C) so that it can compile using GCC under linux, but that was done many moons ago.
I'm getting the following error message:
stubs.c: In function ‘exexc_’:
stubs.c:76:13: warning: implicit declaration of function ‘mmsa_’; did
you mean ‘memset’? [-Wimplicit-function-declaration]
case 'A': mmsa_(); break;
The relevant piece of code i.e. exexc function in stubs.c is:
#include <setjmp.h>
int setjmp(jmp_buf env);
void exexc_(name, i1, i2, i3, i4, i5, namelen)
char *name;
shortint *i1, *i2, *i3, *i4, *i5;
long namelen;
{
static jmp_buf env;
static int first = 1;
static char segment[6];
ipx[0] = *i1;
ipx[1] = *i2;
ipx[2] = *i3;
ipx[3] = *i4;
ipx[4] = *i5;
strncpy(segment, name, namelen);
if( ! first ) longjmp(env, 1);
if( first )
{
first = 0;
setjmp(env);
switch(segment[3]) {
case 'A': mmsa_(); break;
case 'B': mmsb_(); break;
case 'C': mmsc_(); break;
case 'D': mmsd_(); break;
case 'E': mmse_(); break;
case 'F': mmsf_(); break;
case 'G': mmsg_(); break;
case 'H': mmsh_(); break;
case 'I': mmsi_(); break;
case 'J': mmsj_(); break;
case 'K': mmsk_(); break;
case 'L': mmsl_(); break;
default:
fprintf(stderr, "Whoa, attempted to call segment %s\n", segment);
fflush(stderr);
exit(1);
}
fprintf(stderr, "Oops, segment %s didn't call next segment\n", segment);
fflush(stderr);
exit(2);
}
}
What do i need to change in the stubs.c file, so that 'case 'A': mmsa_()' function is declared? If it helps, then mmsa refers to another file i think mmsa.c in the same local directory.
Happy to give more info if you need it. I've not played this game in over 20+ years(!), so any help would be gratefully received.
Upvotes: 0
Views: 302
Reputation: 140256
this is "just" a warning, and the function call doesn't have any parameters, nor any return value is retrieved, so it should be safe to write:
void mmsa_(void);
void mmsb_(void);
...
and so on.
And if you have header files declaring those functions, it's even better as you can include them instead of declaring them directly.
of course you have to link with libraries or objects containing the code of mmsa_
and other functions, or you'll get a link error (the problem would be just moved to the link phase)
as an aside: consider refactoring your code to remove the K&R old-style parameter declaration which is very much outdated and error prone.
Upvotes: 2