If I write this program:
#include <iostream>
namespace foo {
struct bar {
int x;
};
}
int main (void) {
struct foo::bar *a = new struct foo::bar;
delete a;
return 0;
}
and compile it with:
g++ main.cxx -Wall -Wextra
It gives me this warning:
main.cxx: In function ‘int main()’:
main.cxx:10:39: warning: declaration ‘struct foo::bar’ does not declare anything [enabled by default]
However, if I take out the struct keyword after the new keyword:
#include <iostream>
namespace foo {
struct bar {
int x;
};
}
int main (void) {
struct foo::bar *a = new foo::bar;
delete a;
return 0;
}
and compile it the same way, g++ outputs no warnings. Why does g++ output that warning if I use the struct keyword?