Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Initializing non-constant-length array" error when parsing a correct C file. #45

Open
ehboudjema opened this issue Aug 31, 2018 · 3 comments

Comments

@ehboudjema
Copy link

I have the error :
Error: Initializing non-constant-length array
with the following C code :

typedef enum
{
A = 0,
B = 1
} Enum;

int main (){
char arr[((Enum)1)] = "a";
printf("%s\n",arr);
}

The code above compiles and runs correctly using GCC.

@pmetzger
Copy link
Collaborator

Which line is it saying is the error? You haven't specified that.

@ehboudjema
Copy link
Author

It is on line 8: char arr[((Enum)1)] = "a";

@pmetzger
Copy link
Collaborator

pmetzger commented Sep 3, 2018

The code is a little weird, but it should parse because it is indeed a constant. I would recommend trying to figure out what the bug is by diving in to the code, it's the only way you're going to get it fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants