Old C program gives error only on new compiler
I'm trying to compile this software called OSP. If you are familiar with it, this is OSP version one (written circa 1990). It compiles fine an this old Sun Solaris server, but on this new server running SUSE Linux 10 I get errors. Here's the command I'm using to compile:
cc -lm -w *.c I'm probably just using bad command line options causing it to link incorrectly. I'm really rusty on my C code, but I need to get this program working so a professor can teach his OS course. Here are the errors for the first file (all the remaining errors are similar): Code:
cpu.c:198: error: static declaration of âfind_highest_priority_pcbâ follows non-static declaration Code:
#include "cpu.h" Code:
PUBLIC Code:
Code:
PRIVATE |
I can reproduce this with the following
Code:
int func(); Code:
static int func() Code:
PRIVATE PCB *find_highest_priority_pcb(); |
I was hoping to avoid having to edit all the files. Oh well. Where do I need my PRIVATE/static? On both the declarations and the actual function I guess? NM, that is obvious. PRIVATE precedes each function so apparently it needs to precede each declaration as well. At least they should all be in a neat list.
EDIT: Actually, I just noticed there are files like: simcore.private.h I don't see the word PRIVATE defined in any of the files. |
Quote:
Code:
grep -R '^#define[ \t]*PRIVATE' * Quote:
|
Try using the '-ansi' option to the compiler, or '-std=C99'
|
Thanks guys, I will try both of these. I was busy all day yesterday with some administrative junk..
grep was my next move for finding the PRIVATE identifier and I thought there might be command line options for running gcc in an older mode for compatibility. Keeping my fingers crossed! Ok, grep shows that PRIVATE is defined as... you guessed it... static (in three different files: cpu.private.h, files.private.h and memory.private.h ). First I will try the compatibility options in gcc. I don't think I *can* remove the static identifier. A lot of these functions (this being an OS simulator) redefine things that are already defined which is probably why they are defined as static. Removing the static identifier will probably just give me a different set of errors. EDIT: maybe I'm wrong about redefining PRIVATE to mean nothing. It's worth a shot anyway. EDIT2: Darn, the standards change didn't help. Time to try the PRIVATE hack. |
Ah crap, that didn't work because while some functions are declared as PRIVATE, some just use regular old "static"
Ok... how is this possible? Code:
# grep page_in * simcore.c:503: error: static declaration of âpage_inâ follows non-static declaration simcore.c:477: error: previous implicit declaration of âpage_inâ was here |
All times are GMT -5. The time now is 01:55 PM. |