プログラムに取り組んでいますが、Cygwinでコンパイルしようとすると、奇妙なコンパイラエラーが発生します。このプログラムは、Visual Studio C ++ Expressで正常にコンパイルおよび実行されるため、Cygwinと関係があるようです。すべてのエラーは同じタイプのようです。コードの例を次に示します。
int count_records(void)
{
EMPL_TYPE empl_rec;
fstream empl_infile;
empl_infile.open(filepath, ios::in|ios::binary);
int count = 0;
empl_infile.read((char *) &empl_rec, sizeof(empl_rec));
while (!empl_infile.eof())
{
count++;
empl_infile.read((char *) &empl_rec, sizeof(empl_rec));
}
empl_infile.close();
cout << "Records Counted: " << count << endl;
return count;
}
そして、ここにそのセクションに関連するエラーがあります:
Assignment2.cpp:関数int count_records()':
Assignment2.cpp:34: error: no matching function for call to
std :: basic_fstream> :: open(const std :: string&、std :: _ Ios_Openmode)'/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/fstream: 819:注:候補は次のとおりです:void std :: basic_fstream <_CharT、_Traits> :: open(const char *、std :: _ Ios_Openmode)[with _CharT = char、_Traits = std :: char_traits]
繰り返しになりますが、Visual Studioでコンパイルするときにこのエラーは発生せず、Cygwinでのみ発生します。誰かアイデアがあれば教えてください。ありがとうございました。