术语:前向声明与函数原型 [英] Terminology: Forward Declaration versus Function Prototype

查看:47
本文介绍了术语:前向声明与函数原型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对我来说,这些术语在使用 C 编程语言时基本上是同义词.在实践中,我可能更喜欢文件内原型的前向声明",而不是通过头文件包含的原型的函数原型".但是,当您考虑预处理后会发生什么时,即使这是人为的区分.也许我错过了什么.

To me these terms are essentially synonymous when using the C programming language. In practice I might prefer "forward declaration" for in-file prototypes versus "function prototype" for prototypes included via a header file. But even that is an artificial distinction when you consider what happens after preprocessing. Perhaps I'm missing something.

是否就何时使用一个术语与另一个术语达成共识?

Is there a consensus for when to use one term versus the other?

推荐答案

IMO 这些并不是真正的同义词.对我来说,函数原型"指的是函数名称及其参数和返回的类型.它不仅适用于您所谓的前向声明".所有函数都有一个原型.

IMO those are not really synonyms. To me "function prototype" refer to the function name and its parameters' and return's types. It does not only apply to what you call "forward declaration". All functions have a prototype.

我们经常在函数声明与其对应的定义之间进行区分.

We more often make a difference between a function declaration and its corresponding definition.

这篇关于术语:前向声明与函数原型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆