Hi, I’m currently in the process of getting my Particle firmware to compile on Windows so I can write unit tests. I’m basically mocking a bunch of the Particle/Arduino APIs to make it compile. I don’t actually care about making this part work as I’m writing unit tests – not integration tests.
Anyways, as I was compiling in VC++ I came upon some code in a few libraries where arrays were being created like this:
I’m confused here. I thought you had to use
const to set standard array sizing but these arrays are dynamically sized.
I can easily convert this code to use dynamic arrays but I prefer not to change these libraries:
int bufferSize = getBufferSize(messageLength); uint8_t* buffer = new uint8_t[bufferSize];
Can someone explain why the Particle compiler doesn’t complain about the first case? Also, is there a compiler flag I can set so VC++ doesn’t care either?