The following program compiles as a C program:
#include <stdlib.h>
#include <stdio.h>
void f(int n, int m, int x[n][m]) {
printf("x[0][2] = %i\n",x[0][2]);
}
int main() {
int v[][3] = { {0,1,2}, {3,4,5} };
f(2,3,v);
}
However, when compiled as C++ with g++, I have:
main.c:4:29: error: use of parameter outside function body before ‘]’ token
void f(int n, int m, int x[n][m]) {
^
It seems that this feature of C does not exist in C++. Is there any flag that can be given to g++ so that it accepts the code?