vendredi 6 septembre 2019

Why block scope at global namespace is not allowed?

I am curious as to why creating a block scope {} outside any function (in global scope) is not permitted.

I am able to do the following:

void main(){

{
    int i = 4;
}

\\other stuff

}

but not

{
    int i = 4;
}


void main(){
    \\other stuff
}

This issue piqued my interest while implementing a compile time assert, for which I am creating a variable which is to be destroyed immediately after the assert logic is done (to free memory).

Aucun commentaire:

Enregistrer un commentaire