AnsweredAssumed Answered

MQX 4.2.0 _io_write vs const data

Question asked by Rudy Vigneault on Feb 4, 2020
Latest reply on Feb 6, 2020 by Daniel Chen

Hi,

 

We are using MQX 4.2.0 and I was quite surprised that _io_write is defined to take a non-const buffer for the data:

extern _mqx_int    _io_write(MQX_FILE_PTR, void *, _mqx_int);

 

I would have expected the second parameter to be something like const void*, furthermore that it is used in the inline definition of fwrite:

#define  fwrite(ptr,so,no,f) (_io_write(f,ptr,(so)*(no))/(so))

 

My question is: is it safe to assume that neither fwrite nor _io_write will modify the pointer that is given to them?

 

Can there be a problem to remove the const (using a cast) of an array we want to write using fwrite?

 

Thanks!

Outcomes