I’m extending an open source project. After including afxcoll.h in a new C++ file in order to use CStringArray, I get this error:
Error: MFC projects cannot define _ATL_NO_EXCEPTIONS
I suspect I’ll be able to fix the error by adding #defines or changing or rearranging the inclusion of headers, or, if that’s not possible, using something other than CStringArray. What are your suggestions?
Please ask questions in the comments for this question, not in your answer.
You could use
CAtlArray<CString>instead ofCStringArray, as this is compatible with_ATL_NO_EXCEPTIONS. The ATL collection classes are documented here. I normally prefer to use C++ standard library classes such asstd::vectorinstead of the MFC container classes, though.I’d suggest investigating why
_ATL_NO_EXCEPTIONSis defined in this project and whether it can be removed.