Skip to content

Support for variable length arrays #22

@Stewori

Description

@Stewori
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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions