CompilerSource fails to compile

Reporter: faissaloo  |  Status: open  |  Last Modified: October 01, 2017, 02:00:47 AM

I think this merge broke it 8fcd0a9
This is using gcc 4.8.

make -j 3 -C CompilerSource 
g++ -fPIC -std=c++11 -Wall -g -I./JDI/src -I. -MMD -MP -c -o .eobjs/./JDI/src/System/macros.o JDI/src/System/macros.cpp
g++ -fPIC -std=c++11 -Wall -g -I./JDI/src -I. -MMD -MP -c -o .eobjs/./compiler/components/parse_and_link.o compiler/components/parse_and_link.cpp
JDI/src/System/macros.cpp: In member function 'void jdip::macro_function::preparse(std::string, jdi::error_handler*)':
JDI/src/System/macros.cpp:156:121: error: call of overloaded 'toString(pt&)' is ambiguous
       if (!is_letter(val[i])) { herr->error("Expected parameter name following '#' token; `" + val + "'[" + ::toString(i) + "] is not a valid identifier character"); continue; }
                                                                                                                         ^
JDI/src/System/macros.cpp:156:121: note: candidates are:
In file included from JDI/src/System/macros.cpp:31:0:
./JDI/src/General/parse_basics.h:99:12: note: std::string parse_bacics::visible::toString(short int)
     string toString(short);
            ^
./JDI/src/General/parse_basics.h:94:12: note: std::string parse_bacics::visible::toString(int32_t)
     string toString(int32_t);
            ^
./JDI/src/General/parse_basics.h:95:12: note: std::string parse_bacics::visible::toString(int64_t)
     string toString(int64_t);
            ^
./JDI/src/General/parse_basics.h:100:12: note: std::string parse_bacics::visible::toString(short unsigned int)
     string toString(unsigned short);
            ^
./JDI/src/General/parse_basics.h:97:12: note: std::string parse_bacics::visible::toString(uint32_t)
     string toString(uint32_t);
            ^
./JDI/src/General/parse_basics.h:98:12: note: std::string parse_bacics::visible::toString(uint64_t)
     string toString(uint64_t);
            ^
./JDI/src/General/parse_basics.h:101:12: note: std::string parse_bacics::visible::toString(char)
     string toString(char);
            ^
./JDI/src/General/parse_basics.h:102:12: note: std::string parse_bacics::visible::toString(char*) <near match>
     string toString(char*);
            ^
./JDI/src/General/parse_basics.h:102:12: note:   no known conversion for argument 1 from 'pt {aka long unsigned int}' to 'char*'
./JDI/src/General/parse_basics.h:103:12: note: std::string parse_bacics::visible::toString(float)
     string toString(float);
            ^
./JDI/src/General/parse_basics.h:104:12: note: std::string parse_bacics::visible::toString(double)
     string toString(double);
            ^
JDI/src/System/macros.cpp: In member function 'bool jdip::macro_function::parse(std::vector<std::basic_string<char> >&, char*&, char*&, jdip::token_t, jdi::error_handler*) const':
JDI/src/System/macros.cpp:198:132: error: call of overloaded 'toString(std::vector<std::basic_string<char> >::size_type)' is ambiguous
       return errtok.report_error(herr, "Too few arguments to macro function `" + name + "': provided " + ::toString(arg_list.size()) + ", requested " + ::toString(args.size())), false;
                                                                                                                                    ^
JDI/src/System/macros.cpp:198:132: note: candidates are:
In file included from JDI/src/System/macros.cpp:31:0:
./JDI/src/General/parse_basics.h:99:12: note: std::string parse_bacics::visible::toString(short int)
     string toString(short);
            ^
./JDI/src/General/parse_basics.h:94:12: note: std::string parse_bacics::visible::toString(int32_t)
     string toString(int32_t);
            ^
./JDI/src/General/parse_basics.h:95:12: note: std::string parse_bacics::visible::toString(int64_t)
     string toString(int64_t);
            ^
./JDI/src/General/parse_basics.h:100:12: note: std::string parse_bacics::visible::toString(short unsigned int)
     string toString(unsigned short);
            ^
./JDI/src/General/parse_basics.h:97:12: note: std::string parse_bacics::visible::toString(uint32_t)
     string toString(uint32_t);
            ^
./JDI/src/General/parse_basics.h:98:12: note: std::string parse_bacics::visible::toString(uint64_t)
     string toString(uint64_t);
            ^
./JDI/src/General/parse_basics.h:101:12: note: std::string parse_bacics::visible::toString(char)
     string toString(char);
            ^
./JDI/src/General/parse_basics.h:102:12: note: std::string parse_bacics::visible::toString(char*) <near match>
     string toString(char*);
            ^
./JDI/src/General/parse_basics.h:102:12: note:   no known conversion for argument 1 from 'std::vector<std::basic_string<char> >::size_type {aka long unsigned int}' to 'char*'
./JDI/src/General/parse_basics.h:103:12: note: std::string parse_bacics::visible::toString(float)
     string toString(float);
            ^
./JDI/src/General/parse_basics.h:104:12: note: std::string parse_bacics::visible::toString(double)
     string toString(double);
            ^
JDI/src/System/macros.cpp:198:175: error: call of overloaded 'toString(std::vector<std::basic_string<char> >::size_type)' is ambiguous
       return errtok.report_error(herr, "Too few arguments to macro function `" + name + "': provided " + ::toString(arg_list.size()) + ", requested " + ::toString(args.size())), false;
                                                                                                                                                                               ^
JDI/src/System/macros.cpp:198:175: note: candidates are:
In file included from JDI/src/System/macros.cpp:31:0:
./JDI/src/General/parse_basics.h:99:12: note: std::string parse_bacics::visible::toString(short int)
     string toString(short);
            ^
./JDI/src/General/parse_basics.h:94:12: note: std::string parse_bacics::visible::toString(int32_t)
     string toString(int32_t);
            ^
./JDI/src/General/parse_basics.h:95:12: note: std::string parse_bacics::visible::toString(int64_t)
     string toString(int64_t);
            ^
./JDI/src/General/parse_basics.h:100:12: note: std::string parse_bacics::visible::toString(short unsigned int)
     string toString(unsigned short);
            ^
./JDI/src/General/parse_basics.h:97:12: note: std::string parse_bacics::visible::toString(uint32_t)
     string toString(uint32_t);
            ^
./JDI/src/General/parse_basics.h:98:12: note: std::string parse_bacics::visible::toString(uint64_t)
     string toString(uint64_t);
            ^
./JDI/src/General/parse_basics.h:101:12: note: std::string parse_bacics::visible::toString(char)
     string toString(char);
            ^
./JDI/src/General/parse_basics.h:102:12: note: std::string parse_bacics::visible::toString(char*) <near match>
     string toString(char*);
            ^
./JDI/src/General/parse_basics.h:102:12: note:   no known conversion for argument 1 from 'std::vector<std::basic_string<char> >::size_type {aka long unsigned int}' to 'char*'
./JDI/src/General/parse_basics.h:103:12: note: std::string parse_bacics::visible::toString(float)
     string toString(float);
            ^
./JDI/src/General/parse_basics.h:104:12: note: std::string parse_bacics::visible::toString(double)
     string toString(double);
            ^
compiler/components/parse_and_link.cpp: In member function 'virtual int lang_CPP::compile_parseAndLink(EnigmaStruct*, parsed_script**, std::vector<parsed_script*>&, const std::set<std::basic_string<char> >&)':
compiler/components/parse_and_link.cpp:67:56: error: ambiguous overload for 'operator<<' (operand types are 'ideprint' and 'std::map<std::basic_string<char>, dectrip>::size_type {aka long unsigned int}')
     edbg << "Parsed `" << es->scripts[i].name << "': " << scripts[i]->obj.locals.size() << " locals, " << scripts[i]->obj.globals.size() << " globals" << flushl;
                                                        ^
compiler/components/parse_and_link.cpp:67:56: note: candidates are:
In file included from compiler/components/parse_and_link.cpp:31:0:
./backend/ideprint.h:26:13: note: ideprint& ideprint::operator<<(std::string) <near match>
   ideprint &operator<< (std::string);
             ^
./backend/ideprint.h:26:13: note:   no known conversion for argument 1 from 'std::map<std::basic_string<char>, dectrip>::size_type {aka long unsigned int}' to 'std::string {aka std::basic_string<char>}'
./backend/ideprint.h:27:13: note: ideprint& ideprint::operator<<(const char*) <near match>
   ideprint &operator<< (const char* x);
             ^
./backend/ideprint.h:27:13: note:   no known conversion for argument 1 from 'std::map<std::basic_string<char>, dectrip>::size_type {aka long unsigned int}' to 'const char*'
./backend/ideprint.h:28:13: note: ideprint& ideprint::operator<<(void*) <near match>
   ideprint &operator<< (void* x);
             ^
./backend/ideprint.h:28:13: note:   no known conversion for argument 1 from 'std::map<std::basic_string<char>, dectrip>::size_type {aka long unsigned int}' to 'void*'
./backend/ideprint.h:29:13: note: ideprint& ideprint::operator<<(int16_t)
   ideprint &operator<< (int16_t x);
             ^
./backend/ideprint.h:30:13: note: ideprint& ideprint::operator<<(int32_t)
   ideprint &operator<< (int32_t x);
             ^
./backend/ideprint.h:31:13: note: ideprint& ideprint::operator<<(int64_t)
   ideprint &operator<< (int64_t x);
             ^
./backend/ideprint.h:32:13: note: ideprint& ideprint::operator<<(uint16_t)
   ideprint &operator<< (uint16_t x);
             ^
./backend/ideprint.h:33:13: note: ideprint& ideprint::operator<<(uint32_t)
   ideprint &operator<< (uint32_t x);
             ^
./backend/ideprint.h:34:13: note: ideprint& ideprint::operator<<(uint64_t)
   ideprint &operator<< (uint64_t x);
             ^
./backend/ideprint.h:35:13: note: ideprint& ideprint::operator<<(char)
   ideprint &operator<< (char x);
             ^
./backend/ideprint.h:36:13: note: ideprint& ideprint::operator<<(unsigned char)
   ideprint &operator<< (unsigned char x);
             ^
./backend/ideprint.h:37:13: note: ideprint& ideprint::operator<<(double)
   ideprint &operator<< (double x);
             ^
compiler/components/parse_and_link.cpp:98:112: error: ambiguous overload for 'operator<<' (operand types are 'ideprint' and 'std::map<std::basic_string<char>, dectrip>::size_type {aka long unsigned int}')
       edbg << "Parsed `" << es->timelines[i].name <<", moment: " <<es->timelines[i].moments[j].stepNo << "': " << tlines.back()->obj.locals.size() << " locals, " << tlines.back()->obj.globals.size() << " globals" << flushl;
                                                                                                                ^
compiler/components/parse_and_link.cpp:98:112: note: candidates are:
In file included from compiler/components/parse_and_link.cpp:31:0:
./backend/ideprint.h:26:13: note: ideprint& ideprint::operator<<(std::string) <near match>
   ideprint &operator<< (std::string);
             ^
./backend/ideprint.h:26:13: note:   no known conversion for argument 1 from 'std::map<std::basic_string<char>, dectrip>::size_type {aka long unsigned int}' to 'std::string {aka std::basic_string<char>}'
./backend/ideprint.h:27:13: note: ideprint& ideprint::operator<<(const char*) <near match>
   ideprint &operator<< (const char* x);
             ^
./backend/ideprint.h:27:13: note:   no known conversion for argument 1 from 'std::map<std::basic_string<char>, dectrip>::size_type {aka long unsigned int}' to 'const char*'
./backend/ideprint.h:28:13: note: ideprint& ideprint::operator<<(void*) <near match>
   ideprint &operator<< (void* x);
             ^
./backend/ideprint.h:28:13: note:   no known conversion for argument 1 from 'std::map<std::basic_string<char>, dectrip>::size_type {aka long unsigned int}' to 'void*'
./backend/ideprint.h:29:13: note: ideprint& ideprint::operator<<(int16_t)
   ideprint &operator<< (int16_t x);
             ^
./backend/ideprint.h:30:13: note: ideprint& ideprint::operator<<(int32_t)
   ideprint &operator<< (int32_t x);
             ^
./backend/ideprint.h:31:13: note: ideprint& ideprint::operator<<(int64_t)
   ideprint &operator<< (int64_t x);
             ^
./backend/ideprint.h:32:13: note: ideprint& ideprint::operator<<(uint16_t)
   ideprint &operator<< (uint16_t x);
             ^
./backend/ideprint.h:33:13: note: ideprint& ideprint::operator<<(uint32_t)
   ideprint &operator<< (uint32_t x);
             ^
./backend/ideprint.h:34:13: note: ideprint& ideprint::operator<<(uint64_t)
   ideprint &operator<< (uint64_t x);
             ^
./backend/ideprint.h:35:13: note: ideprint& ideprint::operator<<(char)
   ideprint &operator<< (char x);
             ^
./backend/ideprint.h:36:13: note: ideprint& ideprint::operator<<(unsigned char)
   ideprint &operator<< (unsigned char x);
             ^
./backend/ideprint.h:37:13: note: ideprint& ideprint::operator<<(double)
   ideprint &operator<< (double x);
             ^
make: *** [ENIGMA] Error 2
RobertBColton  
Some of those fixes @JoshDreamland told me to make, specifically the use of fixed width integer types for toString. This could even be the cause of recent toString problems being reported like #978 Some of the other changes look like something I have never seen before or am not responsible for.

TheExDeus  

In my branch I enabled C++11 for the CompilerSource project as well, and just used std::to_string instead. It fixed a lot of segfaults.

RodrigoCard  

I just got the same errors when trying to build a game with the latest version 5ef6525

First time with enigma btw, it is not a nice welcome, hahaha

faissaloo  

@RodrigoCard Sorry about that lol.
@RobertBColton Can we get this marked as urgent or something? Since it's completely preventing any use of the compiler?

RodrigoCard  

I fixed this by casting ints where necessary, but I feel that is not the correct way to do that.

diff --git a/CompilerSource/JDI/src/System/macros.cpp b/CompilerSource/JDI/src/System/macros.cpp
index e86bd49..49ea8ec 100644
--- a/CompilerSource/JDI/src/System/macros.cpp
+++ b/CompilerSource/JDI/src/System/macros.cpp
@@ -153,7 +153,7 @@ inline void jdip::macro_function::preparse(string val, error_handler *herr)
         value.push_back(mv_chunk(val.c_str(), push_from, i-push_from)); // Push it onto our value
       while (is_useless_macros(val[++i]));
       push_from = i; // Store current position just in case something stupid happens
-      if (!is_letter(val[i])) { herr->error("Expected parameter name following '#' token; `" + val + "'[" + ::toString(i) + "] is not a valid identifier character"); continue; }
+      if (!is_letter(val[i])) { herr->error("Expected parameter name following '#' token; `" + val + "'[" + ::toString((int)i) + "] is not a valid identifier character"); continue; }
       const size_t asi = i;
       while (is_letterd(val[++i]));
       map<string,int>::iterator pi = parameters.find(val.substr(asi,i-asi));
@@ -195,7 +195,7 @@ bool macro_function::parse(vector<string> &arg_list, char* &dest, char* &destend
 {
   if (arg_list.size() < args.size()) {
     if (arg_list.size() + 1 < args.size())
-      return errtok.report_error(herr, "Too few arguments to macro function `" + name + "': provided " + ::toString(arg_list.size()) + ", requested " + ::toString(args.size())), false;
+      return errtok.report_error(herr, "Too few arguments to macro function `" + name + "': provided " + ::toString((int)arg_list.size()) + ", requested " + ::toString((int)args.size())), false;
     arg_list.push_back("");
   }
   else if ((arg_list.size() > args.size() and args.size() == (unsigned)argc))
diff --git a/CompilerSource/compiler/components/parse_and_link.cpp b/CompilerSource/compiler/components/parse_and_link.cpp
index 9c780b2..3c88e62 100644
--- a/CompilerSource/compiler/components/parse_and_link.cpp
+++ b/CompilerSource/compiler/components/parse_and_link.cpp
@@ -64,7 +64,7 @@ int lang_CPP::compile_parseAndLink(EnigmaStruct *es,parsed_script *scripts[], ve
     // Keep a parsed record of this script
     scr_lookup[es->scripts[i].name] = scripts[i] = new parsed_script;
     parser_main(newcode,&scripts[i]->pev, script_names);
-    edbg << "Parsed `" << es->scripts[i].name << "': " << scripts[i]->obj.locals.size() << " locals, " << scripts[i]->obj.globals.size() << " globals" << flushl;
+    edbg << "Parsed `" << es->scripts[i].name << "': " << (int)(scripts[i]->obj.locals.size()) << " locals, " << scripts[i]->obj.globals.size() << " globals" << flushl;

     // If the script accesses variables from outside its scope implicitly
     if (scripts[i]->obj.locals.size() or scripts[i]->obj.globallocals.size() or scripts[i]->obj.ambiguous.size()) {
@@ -95,7 +95,7 @@ int lang_CPP::compile_parseAndLink(EnigmaStruct *es,parsed_script *scripts[], ve
       // Keep a parsed record of this timeline
       tline_lookup[es->timelines[i].name].push_back(tlines.back());
       parser_main(newcode, &tlines.back()->pev, script_names);
-      edbg << "Parsed `" << es->timelines[i].name <<", moment: " <<es->timelines[i].moments[j].stepNo << "': " << tlines.back()->obj.locals.size() << " locals, " << tlines.back()->obj.globals.size() << " globals" << flushl;
+      edbg << "Parsed `" << es->timelines[i].name <<", moment: " <<es->timelines[i].moments[j].stepNo << "': " << (int)(tlines.back()->obj.locals.size()) << " locals, " << tlines.back()->obj.globals.size() << " globals" << flushl;

       // If the timeline accesses variables from outside its scope implicitly
       if (tlines.back()->obj.locals.size() or tlines.back()->obj.globallocals.size() or tlines.back()->obj.ambiguous.size()) {

RobertBColton  

@faissaloo This we have to get @JoshDreamland's attention for because I honestly don't remember why we made the changes. Secondly I do not understand why we are using our own toString in there. I can see reasons why EDL/GML would need its own, but not why we wouldn't just be using std::to_string in compiler source.

JoshDreamland  

Just use std::to_string in CompilerSource. No sense maintaining our own, anymore, when we don't have to worry about var.

RobertBColton  

@faissaloo Would you want to go ahead and make the change over and send it? I am stuck with the current things I've been working on right now, like bridges.

Also be careful because std::to_string is apparently buggy with MinGW. So I will need to test the PR on Windows first.
http://stackoverflow.com/questions/12975341/to-string-is-not-a-member-of-std-says-g

TheExDeus  

We didn't use std::to_string because we didn't use C++11. I made the change after I enabled it and this is how the file looks: https://github.com/enigma-dev/enigma-dev/blob/GL3.3NormalMatrix/CompilerSource/JDI/src/General/parse_basics.cpp

I still think we should try merging that branch at some point, because you keep fixing problems that are already fixed. Instead you could fix the new ones. :D

faissaloo  

@TheExDeus
The only reason that branch hasn't been merged is because it doesn't compile openGL1 anymore, the issue is literally a 3 line fix (type mismatch between header and actual function) and has some new conflicts, so once those two things are fixed we should be good (unless the merge causes some other obscure issue).
Btw, who mispelt parse_basics as parse_bacics lol.

fundies  

CompilerSource is working here. Can we close this?

faissaloo  

@fundies Nope, it's still not compiling on my OSX partition.

RodrigoCard  

My fork builds on OSX https://github.com/RodrigoCard/enigma-dev/commits/mac-fixes

RodrigoCard  

The only thing not fixed is running the game though the IDE. But everything builds correctly.

If you are OK with the chances I can make a pull request.

RodrigoCard  

I made a pull request #1011 with some fixes. Tested on Ubuntu 16.04 LTS and OS X El Capitan.

RobertBColton  

@fundies has mentioned that it may be because of using std::string that these errors are occurring. The reason being that the string type is defined and then we are using the std string type too.

Please sign in to post comments, or you can view this issue on GitHub.