2

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++?

vmiheer
  • 147
  • 9
  • 2
    Function prototypes are required in C++. Can you provide a [SSCCE](http://sscce.org) that demonstrates the problem you observed? – Greg Hewgill Oct 21 '17 at 05:13
  • @GregHewgill: He's talking about [this C (mis)feature](https://stackoverflow.com/questions/9182763/implicit-function-declarations-in-c). – Nicol Bolas Oct 21 '17 at 05:15
  • 1
    @NicolBolas: I understand, but the question is about C++, not C. – Greg Hewgill Oct 21 '17 at 05:17
  • @GregHewgill: Yes, he's asking if C++ has this C feature. He doesn't need to provide an SSCCE to ask for that. Basically, everything but the last sentence is background information. – Nicol Bolas Oct 21 '17 at 05:17

1 Answers1

4

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.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982