MT5 compiler bug #1 with macros

 

Try to compile ... 

#define RESOURCE_MAKETAG(text) ("RC#"+text)
int OnInit()
  {
  //--- This will produce error "export - unecpected token" and error ") unexpected token"
  Print(RESOURCE_MAKETAG("export"));
  
  //--- This will produce error ") - unexpected token
  Print(RESOURCE_MAKETAG("long"));
  
  //--- This will produce error ") - unexpected token
  Print(RESOURCE_MAKETAG("short"));
  
  //--- Only this will compile without errors
  Print(RESOURCE_MAKETAG("wtf..."));
  
  return(INIT_SUCCEEDED);
  }
 
  1. Why are you stating "MT5 compiler" when you posted in the MQL4 section, (bottom of the Root page?)

  2. Your code compiles just fine in MT4/1170/strict
    'testscr.mq4'    testscr.mq4    1    1
    0 error(s), 0 warning(s), compile time: 1017 msec        1    1

 
Doerk Hilger:

Try to compile ... 

Yes, this fails to compile on MT5, but that's because export, long, and short are being interpreted as keywords of some sort.

This compiles and runs just fine:

#define RESOURCE_MAKETAG(text) ("RC#"+text)
int OnInit()
  {
  //--- This will produce error "export - unecpected token" and error ") unexpected token"
  Print(RESOURCE_MAKETAG("xport"));
  
  //--- This will produce error ") - unexpected token
  Print(RESOURCE_MAKETAG("lng"));
  
  //--- This will produce error ") - unexpected token
  Print(RESOURCE_MAKETAG("shrt"));
  
  //--- Only this will compile without errors
  Print(RESOURCE_MAKETAG("wtf..."));
  
  return(INIT_SUCCEEDED);
  }

Now whether that's a compiler bug or not, I leave the MetaQuotes to decide.

 
Doerk Hilger:

Try to compile ... 

It compiles just fine with beta build 2025.

As usual the release build (2007) has a lot of bugs, the beta solves some of them but has others.

 

This gets errors in 1995, 2007 but not in build 2025...