R
Roy Hills
I'm writing a local patch, which will be applied to several different
source files. To prevent my local variables from clashing with those
in the main source file, I want to create a new scope.
Currently, I'm using the following, which works perfectly and I've
seen used elsewhere:
do {
int i;
int j;
statements;
} while(0);
However, I'm wondering if I need the do/while bit at all, or if I can
just use the braces on their own, e.g:
{
int i;
int j;
statements;
}
This works OK with "gcc -Wall -pedantic -ansi", but I'm wondering if
it's standard C that should be accepted by any compiler. What's
worrying me is that I've not seen this construct used elsewhere, which
makes me question its validity.
Roy
source files. To prevent my local variables from clashing with those
in the main source file, I want to create a new scope.
Currently, I'm using the following, which works perfectly and I've
seen used elsewhere:
do {
int i;
int j;
statements;
} while(0);
However, I'm wondering if I need the do/while bit at all, or if I can
just use the braces on their own, e.g:
{
int i;
int j;
statements;
}
This works OK with "gcc -Wall -pedantic -ansi", but I'm wondering if
it's standard C that should be accepted by any compiler. What's
worrying me is that I've not seen this construct used elsewhere, which
makes me question its validity.
Roy