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

Comments

Projects
None yet
2 participants
@Stewori

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

This comment has been minimized.

Show comment
Hide comment
@rbultje

rbultje Jun 19, 2017

Contributor

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...

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