コードで何が起こっているのかを把握するのに苦労しています。どんな助けでも大歓迎です。ここに私のヘッダー(.cuh)があります:
#include <map>
#include <string>
#include <iostream>
#include "SINS_constants.cuh"
using namespace std;
class SINS_inputManager
{
public:
static SINS_inputManager& getInstance()
{
static SINS_inputManager SINS_inputManager_singleton;
return SINS_inputManager_singleton;
}
void parse(ifstream& cfgfile); // TODO Better read incoming variables, recognize by type in a single loop : template ?
private:
static SINS_inputManager* SINS_inputManager_singleton;
map<string, string> options;
SINS_inputManager();
~SINS_inputManager();
SINS_inputManager(SINS_inputManager const&); // not defined copy constructor
void operator=(SINS_inputManager const&); // not defined = operator
};
これが私の .cu です:
#include "SINS_inputManager.cuh"
void SINS_inputManager::parse(ifstream& cfgfile)
{
cout << "\n";
string id, eq, val;
while(cfgfile >> id >> eq >> val)
{
if (id[0] == '#')
{
cfgfile.ignore(numeric_limits<streamsize>::max(), '\n'); // skip comments
continue;
}
if (eq != "=") throw runtime_error("Syntax error in the parser. Each line should follow :\n'unique parameter name' = 'value'\nA commented line begins with a '#' symbol.\n\n");
options[id] = val;
}
istringstream theStream;
string string_temp;
theStream.clear();
theStream.str(options["INITIAL_INPUT"]);
theStream >> string_temp;
strcpy(INITIAL_INPUT, string_temp.c_str());
theStream.clear();
theStream.str(options["FINAL_OUTPUT"]);
theStream >> string_temp;
strcpy(FINAL_OUTPUT, string_temp.c_str());
theStream.clear();
theStream.str(options["NB_IONS"]);
theStream >> NB_IONS;
theStream.clear();
theStream.str(options["VERBOSE"]);
theStream >> VERBOSE;
theStream.clear();
theStream.str(options["TIME_MAX"]);
theStream >> TIME_MAX;
theStream.clear();
theStream.str(options["DT_OBS"]);
theStream >> DT_OBS;
if(VERBOSE >= 1)
{
cout << "The parser has read the following configuration :\n";
typedef map<string, string>::iterator it_type;
for(it_type iterator = options.begin(); iterator != options.end(); iterator++)
{
cout << "\t" << iterator->first << " = " << iterator->second << "\n";
}
}
}
// private constructor
SINS_inputManager::SINS_inputManager()
{
}
// private destructor
SINS_inputManager::~SINS_inputManager()
{
}
そして、ここにエラーがあります:
/data/pieges/fabian/SINS/code/src/SINS_inputManager.cu(8): error: no operator ">>" matches these operands
operand types are: std::ifstream >> std::string
/data/pieges/fabian/SINS/code/src/SINS_inputManager.cu(12): error: incomplete type is not allowed
/data/pieges/fabian/SINS/code/src/SINS_inputManager.cu(12): error: identifier "numeric_limits" is undefined
/data/pieges/fabian/SINS/code/src/SINS_inputManager.cu(12): error: type name is not allowed
/data/pieges/fabian/SINS/code/src/SINS_inputManager.cu(12): error: no instance of overloaded function "max" matches the argument list
/data/pieges/fabian/SINS/code/src/SINS_inputManager.cu(16): error: identifier "runtime_error" is undefined
/data/pieges/fabian/SINS/code/src/SINS_inputManager.cu(21): error: incomplete type is not allowed
7 errors detected in the compilation of "/tmp/tmpxft_000076aa_00000000-6_SINS_inputManager.cpp1.ii".
CMake Error at SINS_generated_SINS_inputManager.cu.o.cmake:256 (message):
Error generating file
/data/pieges/fabian/SINS/workdir/CMakeFiles/SINS.dir/code/src/./SINS_generated_SINS_inputManager.cu.o
make[2]: *** [CMakeFiles/SINS.dir/code/src/./SINS_generated_SINS_inputManager.cu.o] Erreur 1
make[1]: *** [CMakeFiles/SINS.dir/all] Erreur 2
make: *** [all] Erreur 2
ファイル名を CUDA 拡張子に変更する前は、うまく機能していました。Google を検索したところ、string または string.h のインクルードに問題がある可能性があることがわかりましたが、可能な限りすべての組み合わせを試してみましたが、成功しませんでした。私は何を間違っていますか?
編集: インクルードを追加し、.cu で名前空間 std を使用した後の新しい出力は次のとおりです。
申し訳ありませんが、まったく同じエラーではありません (文字列のみ):
/data/pieges/fabian/SINS/code/src/SINS_inputManager.cu(14): error: no operator ">>" matches these operands operand types are: std::ifstream >> std::string /data/pieges/fabian/SINS/code/src/SINS_inputManager.cu(18): error: incomplete type is not allowed /data/pieges/fabian/SINS/code/src/SINS_inputManager.cu(18): error: identifier "numeric_limits" is undefined /data/pieges/fabian/SINS/code/src/SINS_inputManager.cu(18): error: type name is not allowed /data/pieges/fabian/SINS/code/src/SINS_inputManager.cu(18): error: no instance of overloaded function "max" matches the argument list /data/pieges/fabian/SINS/code/src/SINS_inputManager.cu(22): error: identifier "runtime_error" is undefined /data/pieges/fabian/SINS/code/src/SINS_inputManager.cu(27): error: incomplete type is not allowed 7 errors detected in the compilation of "/tmp/tmpxft_000077e5_00000000-6_SINS_inputManager.cpp1.ii". CMake Error at SINS_generated_SINS_inputManager.cu.o.cmake:256 (message): Error generating file /data/pieges/fabian/SINS/workdir/CMakeFiles/SINS.dir/code/src/./SINS_generated_SINS_inputManager.cu.o make[2]: *** [CMakeFiles/SINS.dir/code/src/./SINS_generated_SINS_inputManager.cu.o]
エラー 1 make[1]: * [CMakeFiles/SINS.dir/all] エラー 2 make: * [all] エラー 2