A
Alex Vinokur
Here are three programs.
--- foo1.cpp ---
int foo;
int main()
{
struct foo {};
sizeof (foo);
return 0;
}
----------------
--- foo2.cpp ---
int foo;
int main()
{
struct foo {};
sizeof foo; // Line#5
return 0;
}
----------------
--- foo3.cpp ---
int foo;
int main()
{
sizeof foo;
return 0;
}
----------------
=== Compilation ===
$ g++ --version
g++ (GCC) 3.3.1 (cygming special)
[---omitted---]
$ g++ foo1.cpp
// No errors, no warnings
$ g++ foo2.cpp
foo2.cpp: In function `int main()':
foo2.cpp:5: error: syntax error before `;' token
$ g++ foo3.cpp
// No errors, no warnings
===================
Is g++ right while compiling foo2.cpp?
Why doesn't the compiler see 'int foo'?
--- foo1.cpp ---
int foo;
int main()
{
struct foo {};
sizeof (foo);
return 0;
}
----------------
--- foo2.cpp ---
int foo;
int main()
{
struct foo {};
sizeof foo; // Line#5
return 0;
}
----------------
--- foo3.cpp ---
int foo;
int main()
{
sizeof foo;
return 0;
}
----------------
=== Compilation ===
$ g++ --version
g++ (GCC) 3.3.1 (cygming special)
[---omitted---]
$ g++ foo1.cpp
// No errors, no warnings
$ g++ foo2.cpp
foo2.cpp: In function `int main()':
foo2.cpp:5: error: syntax error before `;' token
$ g++ foo3.cpp
// No errors, no warnings
===================
Is g++ right while compiling foo2.cpp?
Why doesn't the compiler see 'int foo'?