Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22077

Compiler error: initializer element is not a compile-time constant [duplicate]

$
0
0

I'm compiling this super simple program written in C:

#include <stdio.h>#include <stdlib.h>​int a = 1;int b = a;int main(void) {    printf("%d", b);    return 0;}

and the command I used to compile was:

gcc test.c -o test

but I'm getting this error message:

test.c:5:9: error: initializer element is not a compile-time constantint b = a;        ^1 error generated.

Does anyone know how to possibly solve this problem? I searched similar questions but it turns out that most of them have some other conditions involved (e.g. static variables).

Thanks a lot!


Viewing all articles
Browse latest Browse all 22077

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>