对于 uni 项目,我必须使用 1996 年 GSM 语音编码标准中提供的 ANSI C 代码。 可以在此处找到 zip 存档 https://portal.3gpp.org/desktopmodules/Specifications/SpecificationDetails.aspx?specificationId=281
我有一台运行 OS X 10.11.6 的 MacBook Pro。
当尝试使用 clang 在终端中安装 xcode 来编译其/C 目录(主目录)中的所有不同文件时:
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
它给出了多个错误,例如:
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 */
我认为这是因为新编译器定义了当时未定义的函数?
无论如何,让我可以使用此代码的最简单方法是什么?
最佳答案
POSIX(和其他标准化机构)定义了一个 C 函数 round
,它接受并返回浮点类型。似乎在您的 mathhalf.h 文件中声明的函数 round 可能在 mathhalf.c 文件中实现,并接受并返回整数类型(显然是32位和16位)。此函数与编译器附带的round
发生冲突。
假设该函数在 mathhalf.c
中实现,只需在 .c 和 .h 文件中将其重命名为 intRound
即可。
关于c - 如何在 Mac 上打开并使用 1996 年的旧 ANSI C 代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41569773/