繁体   English   中英

此函数声明中是否存在语法错误?

[英]Is there a syntax error in this function declaration?

这来自一本教科书:

/* This function locates the address of where a new structure
   should be inserted within an existing list.
   It receives the address of a name and returns the address of a
   structure of type NameRec
*/
struct NameRec *linear Locate(char *name)
{
...
}

我了解它会返回指向结构NameRec的指针。 为什么“线性”在那里?为什么“线性”和“位置”之间有空间?

#define linear

即使不是以前,也可以使它在语法上正确(不过,从技术上讲,您可能需要事先使用#undef linear以避免可能发生的宏定义冲突)。

它完全取决于未显示的代码的上下文 到目前为止,在编译器命令行上没有头文件包含或-Dlinear=类的定义,如果没有扩展,它将无法在符合标准的环境中进行编译。

当然,最好的告诉方法是尝试实际编译该东西,然后看看会发生什么:-)

鉴于第13章的解决方案链接 (您要问的那个) 没有提及解决方案中的linear词,我想肯定地说您的书是不正确的。 我会考虑与作者联系(显然目前正在新泽西州的FDU工作)以解决问题。

这是本书中的错字。 在这里查看定位功能:

https://users.ipfw.edu/chansavj/ACY2017/ANSI_C/ANSI_C_4thEd/Solutions%20to%20Exercises%20(Windows)/Solutions/83556-0s/Ch13/pgm13-5ex3.c

(由ta.speot.is发表在评论中)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM