curious48:
Oldsteve writes:"Arduino" is most definitely not a language. The language is C++.
Again, does he mean C?
No. I meant what I wrote - C++.
C++ is backwards compatible.
There are errors in the documentation, but Arduino primarily uses C++, as we've all indicated.
Try this:-
void setup()
{
Serial.begin(115200);
int *pVal = new int[10];
pVal[0] = 123;
Serial.println(pVal[0]);
delete[] pVal;
}
void loop() {}
'new' and 'delete' are only valid in C++, not in C. If Arduino used C, this would not compile.
You could also use 'malloc()' and 'free()', because of the backward compatibility, but in C the 'new' and 'delete' method of handling dynamic memory allocation would not work.
Disclaimer: I'm not in any way saying that dynamic memory allocation in embedded microcontrollers is a good thing, this is just an example. Easier than writing a 'class' example.
But now that we're being very technically precise, shouldn't all of the above references to C++ be renamed as references to C?
Definitely not. As we've all stated, it's C++, not C.
At some point you need to stop arguing and accept facts.