A bug in Visual Studio 2008 when compiling for 64 bit code results in a rather odd warning message. The message is typically shown for the ‘ceil’ mathematical function. The message looks a bit like this:
C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\math.h(136) : warning C4 985: 'ceil': attributes not present on previous declaration. C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\intrin.h(142) : see declaration of 'ceil'
The message occurs when you include both intrin.h and math.h into the same file (either directly or indirectly).
The message is harmless but annoying if you rely on warning free builds as one of your indicators of build quality.
How do you get rid of this warning?
Solution #1: Service Pack
Install a service pack for Visual Studio 2008.
I am not sure which service pack has the fix for this particular bug.
Depending upon which version of Visual Studio 2008 you are using there are many results.
Solution #2: #pragma in stdafx.h
If installing a service pack is not an option you can use, you can simply disable the warning using a #pragma directive in your application’s stdafx.h file.
Add the following line to the stdafx.h. You should find that the warnings are suppressed for any files including that stdafx.h
#pragma warning (disable: 4985)
Solution #3: #pragma in appropriate files
If you don’t want the one-size fits all approach offered by using stdafx.h to suppress this warning you can find where math.h is being included (if intrin.h is included first) or where intrin.h is included (if math.h is included first) and suppress the message during the include. Here is how you do it:
Assume I’ve already included intrin.h
#pragma warning (push) #pragma warning (disable: 4985) // disable the warning message during the include #include <math.h> // this is where I would normally get the warning message #pragma warning (pop)
Assume I’ve already included math.h
#pragma warning (push) #pragma warning (disable: 4985) // disable the warning message during the include #include <intrin.h> // this is where I would normally get the warning message #pragma warning (pop)