首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> C語言 >> 關於C語言

解決 Boost string.hpp 引發的 __int64 重複定義編譯錯誤

     編輯:關於C語言

錯誤現象

error C2632: '__int64' followed by '__int64' is illegal

根因分析

  • Windows SDK config-win32.h 已定義 int64_t 為 __int64
  • Boost cstdint.hpp 再次 typedef __int64 int64_t
  • MSVC 不允許同一型別重複 typedef

最小修正

#undef int64_t
#include <boost/algorithm/string.hpp>

更優雅的方案

// 在包含 Boost 前定義,避免 Boost 重複定義
#ifndef BOOST_HAS_INTRINSIC_INT64
#define BOOST_HAS_INTRINSIC_INT64
#endif
#include <boost/algorithm/string.hpp>

或專案屬性 → C/C++ → 預處理器 → 加入 BOOST_HAS_INTRINSIC_INT64。

適用版本

  • Boost 1.40+
  • Visual Studio 2008/2010/2012/2013
  • Windows SDK 7.0+
  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved