0

この質問は、私の前 の 2 つの質問に大きく関係しています。

プロジェクトにboost 1.51をビルドして含めました。

私の Socket.IO インターフェイス ファイル (pch.h と共に) では、これは私のインクルードの順序です:

#include <wrl.h>
#include <dwrite_1.h>
#include <wincodec.h>
#include <agile.h>
#include "types.h"
#include <cstdint>
#include <stdint.h>
#include <climits>
#include <cstdlib>
#include "boost/cstdint.hpp"
#include "boost/asio.hpp"
#include "boost/bind.hpp"
#include <sio_client_handler.hpp>
#include "boost/thread.hpp"

コードをコンパイルすると、次の出力が得られます (最初の数行のみ)。

エラー 1 エラー C2039: 'int_least8_t' : '`グローバル名前空間'' のメンバーではありません (SocketIO.cpp) c:\program files (x86)\microsoft visual studio 11.0\vc\include\cstdint

エラー 2 エラー C2873: 'int_least8_t': シンボルは using-declaration (SocketIO.cpp) c:\program files (x86)\microsoft visual studio 11.0\vc\include\cstdint で使用できません

エラー 3 エラー C2039: 'int_least16_t' : '`グローバル名前空間'' のメンバーではありません (SocketIO.cpp) c:\program files (x86)\microsoft visual studio 11.0\vc\include\cstdint

エラー 4 エラー C2873: 'int_least16_t': シンボルは using-declaration (SocketIO.cpp) c:\program files (x86)\microsoft visual studio 11.0\vc\include\cstdint では使用できません

上記のエラーは 100 以上あります。

Microsoft Visual Studio 2012 Express C++ を使用していますが、解決策を考え出すことも見つけることもできません。

4

2 に答える 2

0

CライブラリヘッダーとC++ライブラリヘッダー(スタイルが悪い)を混在させています。特に、<cstdint>直前にインクルードしています<stdint.h><cstdint>Visual C ++のIIRCには、<stdint.h>名前空間stdが含まれています。つまり、あなた#include<stdint.h>何もしません(インクルードガードのため)。さらに、int_least8_tなどはnamespacte stdにのみ存在し、グローバル名前空間には存在しません。

VS 2012でそれが正しいかどうかはよくわかりませんが、に飛び込むことで確認できます<cstdint>

いずれの場合も、名前空間std内のこれらのタイプを参照してください。これは、それらが含まれるべき標準準拠の名前空間です。頻繁に使用する場合は(見た目どおり)、使用している名前空間にディレクティブを使用してインポートします。

#include <cstdint>
//#include <stdint.h> <-- leave that one out, it's not C++ standard!

std::int_least8_t myIL8 = 5;

using std::int_least8_t;
int_least8_t anotherIL8 = 42;
于 2013-01-24T15:01:51.403 に答える
0

結局、socket.io クライアントの独自の実装を作成しました。これは仕事関連のプロジェクトだったので、公開するには許可を得る必要があります。

于 2013-02-13T19:52:27.520 に答える