C++/ATL Project throws error C2061: syntax error : identifier '_ATL_FUNC_INFO'

One of my customer reported that they created a ATL Project/MFC CDHtmlDialog based C++ application and they notice the following errors in afxdhtml.h (they created it using VS 2003).

afxdhtml.h(272) : error C2238: unexpected token(s) preceding ';'
afxdhtml.h(289) : error C2061: syntax error : identifier '_ATL_FUNC_INFO'
afxdhtml.h(290) : error C2061: syntax error : identifier '_ATL_FUNC_INFO'

I tried the code piece at my end locally and tested with latest visual studio – I failed to see the issue and it just works for me. Later I done further research on this and found the following:

The #include <afxdhtml.h> directive is placed in the stdafx.h pre-compiled header file before the "using namespace ATL;" directive, and the #define _ATL_NO_AUTOMATIC_NAMESPACE was given previously. Thus, the symbols in the header file which belong to the ATL namespace are not properly resolved. When adding a class from the MFC dialog class wizard, you are given the choice of several dialog base classes, most of which do not require the ATL namespace "using" directive. Thus, the wizard script in default.htm doesn’t make any attempt to ensure that the header file corresponding to the class name come after a using directive.

In Visual Studio 2005 and later versions, the problem doesn’t occur because all references to CComPtr are now prefixed with ::ATL::, alleviating the need to either direct “using namespace ATL;” or to define the macro to eliminate the automatic use of the ATL namespace. So I recommended them to try one of the following to move ahead:

• Remove the #define _ATL_NO_AUTOMATIC_NAMESPACE directive from the stdafx.h header, or
• Move the using namespace ATL; directive before the #include <afxdhtml.h>
• Upgrade to Visual Studio 2005 and above. Also make sure they're fully patched with latest service pack/fixes.