Search code examples
c++implicit-declaration

Is there such thing as implicit declaration in c++?


I was burnt just now. I hadn't enabled warnings while compiling my c code. I was using atof without including stdlib.h. So the atof was using implicit declaration which had default return type of int. So the code wasn't working. I was wondering if the concept of implicit declarations also applies to c++?


Solution

  • C++ does not allow implicit function declarations. Indeed, even C99/11 doesn't allow them. GCC compiles C by default as C89, which is why you got the error you did.