Skip to content

Variables in a loop are overwritten #269

@hogsy

Description

@hogsy

The following code in a binary template is not possible.

...

while( !FEof() )
{
    set_comment_at("We're here...");

    // chunk header, basically tag and size
    struct GroupHeader chunkHeader;
    local uint32_t endOffset = FTell() + chunkHeader.size;

    char chunkData[chunkHeader.size];

    // seek to the end marker, just in case we did anything earlier
    FSeek(endOffset);

    // validate it has an end marker
    uint32_t chunkEnd;
    if ( chunkEnd != GROUP_CHUNK_END )
    {
        set_comment_at( "Hit invalid end!" );
        break;
    }
}

The variables chunkHeader, chunkData and chunkEnd will appear at the end of the file instead. The initial comment set at the start of each iterate will be set correctly however.

Expectation was that there would be an entry for those mentioned above added per loop to the file.

I can work around this by using locals and setting comments manually but obviously not ideal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions