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

Support for variable length arrays #22

Open
Stewori opened this issue Jun 19, 2017 · 1 comment
Open

Support for variable length arrays #22

Stewori opened this issue Jun 19, 2017 · 1 comment

Comments

@Stewori
Copy link

Stewori commented Jun 19, 2017

str1 = whatever;
if (strlen(str1) == 0) return whatever;
char str2[strlen(str1)+ 1];
strcpy(str2, str1);
whatever

becomes something like

str1 = whatever;
if (strlen(str1) == 0) return whatever;
{ char str2[strlen(str1)+ 1];
strcpy(str2, str1);
whatever
}

It could be done near-properly by using alloca, i.e. _alloca (for MSVC):

str1 = whatever;
if (strlen(str1) == 0) return whatever;
{ char* str2 = _alloca(strlen(str1) + 1);
strcpy(str2, str1);
whatever
}

In case it was a concious decision not to Support VLA, then this should be mentioned in the readme.
In general it would be helpful if known limits of c99-to-c89 were documented, at least roughly.

That said, it is still a more than helpful tool. Thanks for creating it!

@rbultje
Copy link
Contributor

rbultje commented Jun 19, 2017

I don't think it was conscious, we implemented what we needed to get ffmpeg to compile and then it was "good enough" for us. I think we'd be happy to merge patches to support other (non-ffmpeg) features, but realistically a lot of people have moved on now that recent versions of MSVC semi-properly support C99...

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