Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to interpret the following error messages in C++
    primarykey
    data
    text
    <p>I have no experience with C++ and was given a code that should supposedly be able to run without any debugging, however, I get a bunch of errors when I try to compile it. I just need some direction on how to start debugging it, any help would be appreciated. Here is the error message:</p> <pre><code>mpicc -c -O3 curvilinear_grid.cpp In file included from parameters.h:12:0, from curvilinear_grid.h:13, from curvilinear_grid.cpp:6: parameter_file_parser.h: In member function ‘int PARAMETER_FILE_PARSER&lt;T&gt;::Parse_Parameter_File()’: parameter_file_parser.h:86:13: error: invalid use of incomplete type ‘std::ifstream {aka struct std::basic_ifstream&lt;char&gt;}’ /usr/include/c++/4.6/iosfwd:113:11: error: declaration of ‘std::ifstream {aka struct std::basic_ifstream&lt;char&gt;}’ parameter_file_parser.h:92:29: error: no matching function for call to ‘getline(std::ifstream&amp;, std::string&amp;)’ parameter_file_parser.h:92:29: note: candidates are: /usr/include/c++/4.6/bits/basic_string.tcc:1070:5: note: template&lt;class _CharT, class _Traits, class _Alloc&gt; std::basic_istream&lt;_CharT, _Traits&gt;&amp; std::getline(std::basic_istream&lt;_CharT, _Traits&gt;&amp;, std::basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp;, _CharT) /usr/include/c++/4.6/bits/basic_string.h:2734:5: note: template&lt;class _CharT, class _Traits, class _Alloc&gt; std::basic_istream&lt;_CharT, _Traits&gt;&amp; std::getline(std::basic_istream&lt;_CharT, _Traits&gt;&amp;, std::basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp;) parameter_file_parser.h:95:21: error: no match for ‘operator&gt;&gt;’ in ‘tokens &gt;&gt; std::ws’ parameter_file_parser.h:95:21: note: candidates are: /usr/include/c++/4.6/bits/basic_string.tcc:998:5: note: template&lt;class _CharT, class _Traits, class _Alloc&gt; std::basic_istream&lt;_CharT, _Traits&gt;&amp; std::operator&gt;&gt;(std::basic_istream&lt;_CharT, _Traits&gt;&amp;, std::basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp;) /usr/include/c++/4.6/bits/istream.tcc:957:5: note: template&lt;class _CharT2, class _Traits2&gt; std::basic_istream&lt;_CharT, _Traits&gt;&amp; std::operator&gt;&gt;(std::basic_istream&lt;_CharT, _Traits&gt;&amp;, _CharT2*) /usr/include/c++/4.6/bits/istream.tcc:925:5: note: template&lt;class _CharT, class _Traits&gt; std::basic_istream&lt;_CharT, _Traits&gt;&amp; std::operator&gt;&gt;(std::basic_istream&lt;_CharT, _Traits&gt;&amp;, _CharT&amp;) /usr/include/c++/4.6/istream:709:5: note: template&lt;class _Traits&gt; std::basic_istream&lt;char, _Traits&gt;&amp; std::operator&gt;&gt;(std::basic_istream&lt;char, _Traits&gt;&amp;, unsigned char&amp;) /usr/include/c++/4.6/istream:714:5: note: template&lt;class _Traits&gt; std::basic_istream&lt;char, _Traits&gt;&amp; std::operator&gt;&gt;(std::basic_istream&lt;char, _Traits&gt;&amp;, signed char&amp;) /usr/include/c++/4.6/istream:756:5: note: template&lt;class _Traits&gt; std::basic_istream&lt;char, _Traits&gt;&amp; std::operator&gt;&gt;(std::basic_istream&lt;char, _Traits&gt;&amp;, unsigned char*) /usr/include/c++/4.6/istream:761:5: note: template&lt;class _Traits&gt; std::basic_istream&lt;char, _Traits&gt;&amp; std::operator&gt;&gt;(std::basic_istream&lt;char, _Traits&gt;&amp;, signed char*) parameter_file_parser.h:95:51: error: no matching function for call to ‘getline(std::istringstream&amp;, std::string&amp;, char)’ parameter_file_parser.h:95:51: note: candidates are: /usr/include/c++/4.6/bits/basic_string.tcc:1070:5: note: template&lt;class _CharT, class _Traits, class _Alloc&gt; std::basic_istream&lt;_CharT, _Traits&gt;&amp; std::getline(std::basic_istream&lt;_CharT, _Traits&gt;&amp;, std::basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp;, _CharT) /usr/include/c++/4.6/bits/basic_string.h:2734:5: note: template&lt;class _CharT, class _Traits, class _Alloc&gt; std::basic_istream&lt;_CharT, _Traits&gt;&amp; std::getline(std::basic_istream&lt;_CharT, _Traits&gt;&amp;, std::basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp;) parameter_file_parser.h:96:14: error: no match for ‘operator&gt;&gt;’ in ‘tokens &gt;&gt; std::ws’ parameter_file_parser.h:96:14: note: candidates are: /usr/include/c++/4.6/bits/basic_string.tcc:998:5: note: template&lt;class _CharT, class _Traits, class _Alloc&gt; std::basic_istream&lt;_CharT, _Traits&gt;&amp; std::operator&gt;&gt;(std::basic_istream&lt;_CharT, _Traits&gt;&amp;, std::basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp;) /usr/include/c++/4.6/bits/istream.tcc:957:5: note: template&lt;class _CharT2, class _Traits2&gt; std::basic_istream&lt;_CharT, _Traits&gt;&amp; std::operator&gt;&gt;(std::basic_istream&lt;_CharT, _Traits&gt;&amp;, _CharT2*) /usr/include/c++/4.6/bits/istream.tcc:925:5: note: template&lt;class _CharT, class _Traits&gt; std::basic_istream&lt;_CharT, _Traits&gt;&amp; std::operator&gt;&gt;(std::basic_istream&lt;_CharT, _Traits&gt;&amp;, _CharT&amp;) /usr/include/c++/4.6/istream:709:5: note: template&lt;class _Traits&gt; std::basic_istream&lt;char, _Traits&gt;&amp; std::operator&gt;&gt;(std::basic_istream&lt;char, _Traits&gt;&amp;, unsigned char&amp;) /usr/include/c++/4.6/istream:714:5: note: template&lt;class _Traits&gt; std::basic_istream&lt;char, _Traits&gt;&amp; std::operator&gt;&gt;(std::basic_istream&lt;char, _Traits&gt;&amp;, signed char&amp;) /usr/include/c++/4.6/istream:756:5: note: template&lt;class _Traits&gt; std::basic_istream&lt;char, _Traits&gt;&amp; std::operator&gt;&gt;(std::basic_istream&lt;char, _Traits&gt;&amp;, unsigned char*) /usr/include/c++/4.6/istream:761:5: note: template&lt;class _Traits&gt; std::basic_istream&lt;char, _Traits&gt;&amp; std::operator&gt;&gt;(std::basic_istream&lt;char, _Traits&gt;&amp;, signed char*) parameter_file_parser.h:96:41: error: no matching function for call to ‘getline(std::istringstream&amp;, std::string&amp;)’ parameter_file_parser.h:96:41: note: candidates are: /usr/include/c++/4.6/bits/basic_string.tcc:1070:5: note: template&lt;class _CharT, class _Traits, class _Alloc&gt; std::basic_istream&lt;_CharT, _Traits&gt;&amp; std::getline(std::basic_istream&lt;_CharT, _Traits&gt;&amp;, std::basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp;, _CharT) /usr/include/c++/4.6/bits/basic_string.h:2734:5: note: template&lt;class _CharT, class _Traits, class _Alloc&gt; std::basic_istream&lt;_CharT, _Traits&gt;&amp; std::getline(std::basic_istream&lt;_CharT, _Traits&gt;&amp;, std::basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp;) parameter_file_parser.h:107:8: error: invalid use of incomplete type ‘std::ifstream {aka struct std::basic_ifstream&lt;char&gt;}’ /usr/include/c++/4.6/iosfwd:113:11: error: declaration of ‘std::ifstream {aka struct std::basic_ifstream&lt;char&gt;}’ make: *** [curvilinear_grid.o] Error 1 </code></pre> <p>Code relevant to error messages:</p> <pre><code> // File: parameter_file_parser.h // Desc: Parser of the parameter input file to change default parameter values #ifndef __PARAMETER_FILE_PARSER__ #define __PARAMETER_FILE_PARSER__ #include &lt;iostream&gt; #include &lt;map&gt; #include &lt;string&gt; #include &lt;algorithm&gt; template&lt;class T=double&gt; class PARAMETER_FILE_PARSER { public: PARAMETER_FILE_PARSER(string filename) : parameter_filename(filename) {param_map=NULL;} ~PARAMETER_FILE_PARSER() {if(param_map) delete param_map;} int Parse_Parameter_File(); bool Get_Value(string key, int&amp; value) { if(!param_map) return false; map&lt;string,string&gt;::iterator i = (*param_map).find(key); if(i != (*param_map).end()){ value = atoi(i-&gt;second.c_str()); return true; }else return false; } bool Get_Value(string key, double&amp; value) { if(!param_map) return false; map&lt;string,string&gt;::iterator i = (*param_map).find(key); if(i!=(*param_map).end()){ value = atof(i-&gt;second.c_str()); return true; }else return false; } bool Get_Value(string key, string&amp; value) { if(!param_map) return false; map&lt;string,string&gt;::iterator i = (*param_map).find(key); if(i!=(*param_map).end()){ string raw_val = i-&gt;second; size_t ip1,ip2; ip1 = raw_val.find('"'); ip2 = raw_val.find('"',ip1+1); if(ip1!=string::npos &amp;&amp; ip2!=string::npos){ value = raw_val.substr(ip1+1,ip2-ip1-1); return true; }else return false; }else return false; } /* bool Get_Value(string key, bool&amp; value) { if(!param_map) return false; map&lt;string,string&gt;::iterator i = (*param_map).find(key); if(i!=(*param_map).end()){ switch(i-&gt;second){ //make lowercase case "true": value = true;break; case "false": value = false;break; } return true; }else return false; }else return false; } */ bool Processed() {return param_map!=NULL;} private: map&lt;string, string&gt; *param_map; string parameter_filename; }; //***************************************************************************** // Parsing parameter_filename and populating the parameters map //***************************************************************************** template&lt;class T&gt; int PARAMETER_FILE_PARSER&lt;T&gt;::Parse_Parameter_File() { ifstream pfile(parameter_filename.c_str()); if (!pfile.is_open()) {cout &lt;&lt; "Unable to open parameter file:parameter_filename"&lt;&lt;endl;return 0;} param_map = new map&lt;string, string&gt;(); string line,key, value; while (getline(pfile, line)) { istringstream tokens(line); while(tokens &gt;&gt; ws &amp;&amp; getline(tokens, key, '=') &amp;&amp; tokens &gt;&gt; ws &amp;&amp; getline(tokens, value)){ key.erase(remove(key.begin(),key.end(),' '),key.end()); size_t i = value.find("//"); if(i!=string::npos) { value = value.substr(0,i-1); value.erase(remove(value.begin(),value.end(),' '),value.end()); } (*param_map)[key] = value; } } pfile.close(); return 1; } //***************************************************************************** #endif </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload