在 Windows 平台使用 MSVC 編譯包含 <boost/algorithm/string.hpp> 的專案時,出現錯誤:
error C2632: '__int64' followed by '__int64' is illegal
cstdint.h (或 Windows SDK) 已定義 int64_t 為 __int64。cstdint.hpp 內部又嘗試 typedef __int64 int64_t;。__int64 被重複 typedef,觸發 C2632。在包含 Boost 標頭**之前**,先取消定義衝突的巨集/型別:
#undef int64_t
#include <boost/algorithm/string.hpp>
BOOST_HAS_STDINT_H (告知 Boost 使用系統 <stdint.h>)。<cstdint> (C++11) 而非手動定義整數型別。加入 #undef int64_t 後重新編譯,錯誤消失,專案正常建置。