ISO C incompatibilities

D

djk9636

Greetings,

I have some old C code that quit compiling on Linux because the compiler
doesn't like the function prototypes not matching the function
definitions. I know Sun has a compiler switch that overrides this, but
I can't seem to find how to do it on Linux.

I'm using "gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)"

I use the -U__STDC__ directive when I do the compile, but the compile
errors out. The error message is:

"You need a ISO C conforming compiler to use the glibc headers"

If I take the switch out, some of it compiles and even links...

You might call me lazy, but I would rather not make coding changes.
This product runs on many OS's and I'd have to compile/test/package on
all of them.

Thank you for reading my post,
Dean
 
R

Robert Harris

djk9636 said:
Greetings,

I have some old C code that quit compiling on Linux because the compiler
doesn't like the function prototypes not matching the function
definitions.
Well, you are on your own! To conform to the C language, prototypes must
match function definitions. And if they don't match, then the function
may well not do what you expect in any case.

Robert
 
T

Tommy Reynolds

I have some old C code that quit compiling on Linux because the compiler
doesn't like the function prototypes not matching the function
definitions. I know Sun has a compiler switch that overrides this, but
I can't seem to find how to do it on Linux.

Google.com is your friend. Try searching for the "mkptypes" program:
it will transform your K&R code into ANSI-style code. Add an
additional step to your Makefile's to do the transformation.

HTH.
 
A

Alan Balmer

I have some old C code that quit compiling on Linux because the compiler
doesn't like the function prototypes not matching the function
definitions.

You should be grateful :)

I have no suggestion except the obvious one - fix the prototypes. Then
you can fix all the places where functions are called with the wrong
parameters.

If the problem is systematic, you might be able to write a translator
in Awk or Perl which does most of the work for you.
 
J

jacob navia

You might call me lazy, but I would rather not make coding changes.
This product runs on many OS's and I'd have to compile/test/package on
all of them.

But this product doesn't run. It *seems* to run until you unexpectedly
receive a strange message, the program disappears and the
user has lost all data.

Crash.

If the wrong calls aren't used often this "product" gives you
the impression that is running but actually it is a flawed
product.

If you do not want to change it throw it away.
 
?

=?ISO-8859-1?Q?=22Nils_O=2E_Sel=E5sdal=22?=

djk9636 said:
Greetings,

I have some old C code that quit compiling on Linux because the compiler
doesn't like the function prototypes not matching the function
definitions. I know Sun has a compiler switch that overrides this, but
I can't seem to find how to do it on Linux.

I'm using "gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)"

I use the -U__STDC__ directive when I do the compile, but the compile
errors out. The error message is:
Drop that, and try the -ansi switch
 
D

djk9636

I want to thank you all for your replies. The idea of using mkptypes
would be faster in the short term, (my boss would probably like that,)
but in the long term coding changes will be necessary anyway. Other
than those options, I'd need to rewrite the whole application...

Thanks Again,
-Dean
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top