So I was messing around with C code and I noticed something about the way that gcc and clang handle code.
If I declare an array in file scope using a variable size, clang compiles with no problem but gcc throws an error. My guess is that it has to do with which compiler flags are/are not enabled by default in gcc/clang, but I would be glad if someone could tell me exactly why this thing is happening and maybe suggest some online resource where I can learn more about this functionality.
Here is an arbitrary example of the code that throws the error -
typedef struct node{
int data;
struct node *next;
struct node *prev;
}node;
const int N = 1000;
node *table[N]; // This is where the error is
int main() {
return 0;
running clang example.c
with no other flags compiles fine running gcc example.c
with no other flags throws an error -
example.c:9:7: error: variably modified 'table' at file scope
9 | node *table[N];
| ^~~~