VC++ 10 で次のソースをコンパイルするi
と、静的リンケージが割り当てられますが42
、G++ 4.5.1 ではi
、source2.cpp の外部リンケージが割り当てられ42
ます。
基準に従った標準確認動作とは何か、またはその理由についてのアイデアはありますか?
// source1.cpp
#include <iostream>
static int i = 0;
int h();
void foo()
{
int i;
{
extern int i;
i = 42;
}
}
int main()
{
foo();
std::cout << i << std::endl;
std::cout << h() << std::endl;
}
// source2.cpp
int i;
int h() { return i; }