-->
Page 1 of 1

Dynamic Arrays? Does this really work?

PostPosted: Sat Dec 02, 2017 10:25 pm
by inflector
I'm an experienced C++ programmer and I have never seen code like this that would compile.

From lines 77 to 82 of the WifiTelnetToSerial example project:

Code: Select all  //check UART for data
  if(Serial.available()){
    size_t len = Serial.available();
    uint8_t sbuf[len];
    Serial.readBytes(sbuf, len);


How does one define an array of uint8_t based on a dynamic value not known at compile time? This seems like something I'd see in a dynamic interpreted language, I've never seen it in a C/C++ dialect.

How does this compile? Is this a bug?

Re: Dynamic Arrays? Does this really work?

PostPosted: Thu Dec 07, 2017 4:17 pm
by inflector
I found out this is a C11 standard feature that gcc has but not most C++ compilers.