The scope of the using statement depends on where it is located in the code:
http://stackoverflow.com/questions/1677778/why-enclose-blocks-of-c-code-in-curly-braces
http://stackoverflow.com/questions/2759371/in-c-do-braces-act-as-a-stack-frame
- Placed at the top of a file, it has scope throughout that file.
- If this is a header file, it will have scope in all files that include that header. In general, this is "not a good idea" as it can have unexpected side effects
- Otherwise the using statement has scope within the block that contains it from the point it occurs to the end of the block. If it is placed within a method, it will have scope within that method. If it is placed within a class definition it will have scope within that class.
http://stackoverflow.com/questions/1677778/why-enclose-blocks-of-c-code-in-curly-braces
http://stackoverflow.com/questions/2759371/in-c-do-braces-act-as-a-stack-frame
void foo(int[]);
void bar(void);
void foobar(int);
void foobar(int flag) {
if (flag) {
int big[100000000];
foo(big);
}
bar();
}
gives:_foobar:
pushl %ebp
movl %esp, %ebp
movl $400000008, %eax
call __alloca
cmpl $0, 8(%ebp)
je L2
leal -400000000(%ebp), %eax
movl %eax, (%esp)
call _foo
L2:
call _bar
leave
ret
No comments:
Post a Comment