C ++中的外部函数 [英] Externing functions in C++

查看:140
本文介绍了C ++中的外部函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当在cpp文件中外部函数时,编译器对这些函数的处理是不同的吗?

When externing a function in the cpp file does the compiler treat these differently?

extern void foo(char * dataPtr);  
void foo(char *);
extern void foo(char * );  



我想知道,因为我看到所有这些在代码中,不知道有什么区别。 p>

I am wondering because I have see all these in code and not sure what the difference is.

推荐答案

个案:

 extern void foo(char * dataPtr);  

函数具有外部链接,因此extern不是必需的 - 这等同于: p>

functions have external linkage by default, so the extern is not necessary - this is equivalent to:

 void foo(char * dataPtr);

参数名称在函数声明中不重要,因此上述等价于:

Parameter names are not significant in function declarations, so the above is equivalent to:

 void foo(char * );  

使用您最喜欢的方式。

这篇关于C ++中的外部函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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