Porting an old UNIX application to FreeBSD 9.0 64bit

Hi,
I've got a piece of software that was written with curses in 1994.
At that time, I think curses has no function called "box".
My application defined a function called "box"
So that these symbols collided.
How would I "shadow" the curses' box function and make use of my own box function with the cc compiler?
Thanks
Jack
 
Assuming you need to use both old and current libraries in different installations, and that your code i written in C, you can use a pragma like #ifdef to define your box function if the library is old, and rename it to a new function if using the new libraries. But probably this is an extra effort that you don't need, and therefore simply renaming the function will give you a cleaner result.
 
Hello guys,
Thanks for your responses.

Here I've an errors I am not quite sure how to resolve while preserving the original program behaviour.


I've got a prototype at the very beginning of my module

u_short htons();

the error is
tcp.c:8: error: expected ')' before '?' token

What would I do to solve this problem since I don't have any '?' token written down on that line.
 
The name htons(3) is already defined in netinet/in.h that you probably include to tcp.c.
The htons defined in the system header however is not a regular function but a macro instead, which uses the ?-Operator to decide whether a permutation of its' parameter is required or not.

To resolve this, rename the htons function and all calls to it.
 
Thanks xibo,
I don't remember what I should rename it to as my memory worn out.
BTW: how do I locate where netinet/in.h is?
I try whereis in.h to no avail.
 
The link he posted to the manpage on the function says its in standard library, so should just be in its folder in include.

He didn't suggest that you get rid of the h file though, he was saying rename it in your program, so you wouldn't have to touch the standard library files.

As a side note, have you tried just getting the older version of curses to compile and using LD_PRELOAD before the appname to run it?

Seems like that might be easier, if the old version compiles.
 
Back
Top