Search code examples
c++visual-studio-2010visual-c++-2010

ceil works without including <cmath> in visual c++ 2010


I just wrote a simple C++ program in Visual Studio 2010 and I use ceil function. But I forgot to include the <cmath> and only included the <iostream>. Surprisingly my code compiled successfully and ran without any error. I read a C++ book and it clearly says that to use ceil function you must include <cmath> or <math.h>. Why this happens? Can anyone explain me? Thanks!


Solution

  • The header is indirectly included from some other (indirectly) included header.

    To find out which one, enable 'keep preprocessed source' (/P) from the project options and inspect the resulting (*.i) file

    Update Just found out that VS2010 has renamed the related option:

    enter image description here