How do I open and use old ANSI C code from 1996 on a Mac?

225 views Asked by At

For a uni project I have to use the ANSI C code supplied in the GSM speech coding standard from 1996. the zip archive can be found here https://portal.3gpp.org/desktopmodules/Specifications/SpecificationDetails.aspx?specificationId=281

I have a MacBook Pro running OS X 10.11.6.

when trying to compile all the different files in its /C directory (main directory) with xcode installed in terminal using clang:

clang dtx.c err_conc.c globdefs.c gsm_hr.c homing.c host.c mathdp31.c mathhalf.c sp_dec.c sp_enc.c sp_frm.c SP_rom.c sp_sfrm.c utils.c vad.c male.inp -o GSMHR

it gives multiple errors like:

In file included from dtx.c:37:
./mathhalf.h:75:11: warning: incompatible redeclaration of library function 'round' [-Wincompatible-library-redeclaration]
Shortword round(Longword L_var1);      /* 1 ops */

I assume this is because of the new compiler having functions defined that weren't defined back then?

Anyways, what is the easiest way for me to make this code usable?

1

There are 1 answers

3
tofro On

POSIX (and other standardisation bodies) define a C function round that takes and returns a floating point type. The function round that seems to be declared in your mathhalf.h file is probably implemented in the mathhalf.c file and takes and returns integer types (32 and 16 bits, apparently). This function clashes with the round that comes with the compiler.

Assuming the function is implemented in mathhalf.c, simply rename it to, for example, intRound in both the .c and the .h file.