[英]Is there such thing as implicit declaration in c++?
I was burnt just now. 我刚才被烧死了 I hadn't enabled warnings while compiling my c code. 编译我的C代码时未启用警告。 I was using atof
without including stdlib.h
. 我正在使用atof
而不包含stdlib.h
。 So the atof
was using implicit declaration which had default return type of int
. 所以atof
使用的是隐式声明,其默认返回类型为int
。 So the code wasn't working. 因此代码无法正常工作。 I was wondering if the concept of implicit declarations also applies to c++? 我想知道隐式声明的概念是否也适用于c ++?
C++ does not allow implicit function declarations . C ++不允许隐式函数声明 。 Indeed, even C99/11 doesn't allow them. 确实,即使C99 / 11也不允许它们。 GCC compiles C by default as C89, which is why you got the error you did. GCC默认将C编译为C89,这就是为什么您得到错误的原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.