連結器工具錯誤 LNK2004
gp relative fixup overflow to 'target';簡短區段 『section』 太大或超出範圍。
區段太大。
若要解決此錯誤,請透過 #pragma section(“.sectionname”, read, write, long) __declspec(allocate(".sectionname"))
和在數據定義和宣告上使用,明確地將數據放入長區段中,以減少簡短區段的大小。 例如,
#pragma section(".data$mylong", read, write, long)
__declspec(allocate(".data$mylong"))
char rg0[1] = { 1 };
char rg1[2] = { 1 };
char rg2[4] = { 1 };
char rg3[8] = { 1 };
char rg4[16] = { 1 };
char rg5[32] = { 1 };
您也可以將邏輯群組數據移至其本身的結構,該結構會是大於8個字節的數據集合,編譯程式會在長數據區段中配置。 例如,
// from this...
int w1 = 23;
int w2 = 46;
int w3 = 23*3;
int w4 = 23*4;
// to this...
struct X {
int w1;
int w2;
int w3;
int w4;
} x = { 23, 23*2, 23*3, 23*4 };
錯誤後面接著嚴重錯誤 LNK1165
。