Code Generation Error

 

Hi,

In compilation process of MT5 EA, I got "Code Generation Error" at Line 1 Column 1.  I have fixed other errors and warnings before this error.  I can't figure out where to fix.

What are probable causes of this error ?

I have been trying to convert an EA in MT4 which runs without errors to MT5. I think that this error may result from difference between MT5 and MT4.

Thank you in advance for any advice.

 
Source (MQL4 and MQL5)?
 
My check engine light just came on... What is the issue with my vehicle?
 

I am trying to re-write a working mql4 EA to the mql5 version. First I copied and pasted the full mql4 version into a new mql5 EA and then started to solve all compilation errors one by one.

When I get rid of the last error a new error always shows; the same "Code Generation Error" at Line 1 Column 1.

Posting the full EA here would be to much code so my question is how can I try to identify the problem?

Currently I have no idea what is wrong or from what line in the code the issue come from, possible to find this out?

Thanks in advance for any advice!

 

I have simular problem with a script. I compiled it yesterday without problems. Today I extended it and get "Code generation error" line 1, 1.

After rearranging my include files, the compiler was able to detect a static function was missing.

It is an abstract class, but I do not instantiate an object. I use only the static methods of the class and that worked so far.

 
You'd see this error when an abstract function is not overridden by the derived class. So if you're implementing sort of interface, maybe. You need to show some code at least.
 

Hi,

I had the same problem after I translated an MQL4 Expert Advisor to MQL5. I ended up marking lots of the code as comment and reactivate it in small blocks. Eventually I got the new EA compiled.

The reason for this error is probably that it is not a compilation error but a linking error (post processing to assemble the compiled code into an executable program). So your syntax and commands are probably all good (otherwise compilation wouldn't even start). In my case I managed to pinpoint the problem to one single function; with the body of the function commented out the compilation would end successfully. With the body of this function active I got the problem back. I solved it by implementing the function in another way. There were no syntax errors or anything so I never found out why the original function's body was causing that problem.

Hope this helps a bit.

 

Testing what function caused the error helped to find the error. Since I compiled successfully I was changing mostly one function. I extended and rearranged my include files a lot before I got the error. My complicated include files may be responsible that the compiler did accept the missing function and linking failed because of it.

It might help to print linker errors?

 
bucket:

...

It might help to print linker errors?

Yes this error is annoying and outright ridiculous because other OOP languages like C++ have this since ages. (I mean detailed linker errors)

Reason: