Possible loss of data due to type conversion bug?

Back to topics list To post a new topic, please log in or register
avatar
20
niquedegraaff 2016.04.14 21:04
 

The next very simple piece of code...

// Get chart dimensions
int chart_height = ChartGetInteger(0, CHART_HEIGHT_IN_PIXELS, 0);

 .. produces a beautiful compiler warning.. :

possible loss of data due to type conversion Nique - BO5M.mq4 64 22

Is this a bug?
avatar
1200
FMIC 2016.04.14 23:08 #
 
ChartGetInteger() returns a "long", not an "int".
avatar
20
niquedegraaff 2016.04.14 23:32 #
 
Then they need to fix this doc:
Example:
void OnStart()
  {
   int height=ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS,0);
   int width=ChartGetInteger(0,CHART_WIDTH_IN_PIXELS,0);
   Print("CHART_HEIGHT_IN_PIXELS =",height,"pixels");
   Print("CHART_WIDTH_IN_PIXELS =",width,"pixels");
  }
https://docs.mql4.com/chart_operations/chartgetinteger

avatar
1200
FMIC 2016.04.14 23:54 #
 
The docs are correct! It is just the example that is outdated for "strict" compilation, although probably still valid for the old style of non-strict compilation.
Back to topics list  

To add comments, please log in or register