VS2010: IntelliSense: #error directive: Please use the /MD switch for _AFXDLL builds

สร้าง Project ใหม่แบบ MFC และเลือก Shared Library พอสั่งรันแล้วเกิด Error ดังนี้

IntelliSense: #error directive: Please use the /MD switch for _AFXDLL builds

ให้แก้ไขโดยคลิกขวาที่ Project เลือก properties > Configuration Properties > C/C++ > Code Generation

จากนั้นให้ดูที่ Runtime Libraryจะมีค่า default เป็น Multi-threaded Debug DLL (/MDd) แต่ไม่ใช่ตัวหนา

จากนั้นให้เปลี่ยนเป็นค่าอื่นก่อน แล้วเลือกกลับมาเป็น Runtime Library ให้เป็น Multi-threaded Debug DLL (/MDd) อีกครั้ง จะสังเกตุเห็นได้ว่า คำว่า Multi-threaded Debug DLL (/MDd) กลายเป็นตัวหนาแล้ว เป็นอันเสร็จ

อันนี้เข้าใจว่าเป็น Bug ของ VC 2010

vs2010

ที่มา: connect.microsoft.combasharatspace.blogspot.com