編譯器警告 (層級 1) C4503
'identifier' :超過裝飾名稱長度,名稱已截斷
備註
此編譯程式警告已經過時,而且不會在Visual Studio 2017和更新版本中產生。
裝飾名稱超過編譯程式限制 (4096),且已截斷。 若要避免這個警告和截斷,請減少使用的自變數數目或標識碼的名稱長度。 超過編譯程式限制的裝飾名稱已套用哈希,而且不會發生名稱衝突的危險。
使用舊版 Visual Studio 時,當您的程式代碼重複包含範本特製化的範本時,可能會發出這個警告。 例如,地圖地圖(來自C++標準連結庫)。 在此情況下,您可以將 typedefs 設為包含地圖的類型( struct
例如)。
不過,您可能會決定不要重新建構程序代碼。 您可以寄送產生 C4503 的應用程式,但如果您在截斷符號上收到鏈接時間錯誤,可能更難判斷錯誤中的符號類型。 偵錯可能更困難;調試程式可能很難將符號名稱對應至類型名稱。 不過,程序的正確性不受截斷名稱影響。
範例
下列範例會在 Visual Studio 2017 之前,在編譯程式中產生 C4503:
// C4503.cpp
// compile with: /W1 /EHsc /c
// C4503 expected
#include <string>
#include <map>
class Field{};
typedef std::map<std::string, Field> Screen;
typedef std::map<std::string, Screen> WebApp;
typedef std::map<std::string, WebApp> WebAppTest;
typedef std::map<std::string, WebAppTest> Hello;
Hello MyWAT;
此範例示範重寫程式代碼以解析 C4503 的其中一種方式:
// C4503b.cpp
// compile with: /W1 /EHsc /c
#include <string>
#include <map>
class Field{};
struct Screen2 {
std::map<std::string, Field> Element;
};
struct WebApp2 {
std::map<std::string, Screen2> Element;
};
struct WebAppTest2 {
std::map<std::string, WebApp2> Element;
};
struct Hello2 {
std::map<std::string, WebAppTest2> Element;
};
Hello2 MyWAT2;