开发者

initializer-string for array of array of chars is too long

开发者 https://www.devze.com 2023-01-09 13:30 出处:网络
I am making a patcher for a game but I get the error \"initializer-string for array of array of chars is too long\" from Mingw. I am trying to make a multidimensional array of chars to contain what fu

I am making a patcher for a game but I get the error "initializer-string for array of array of chars is too long" from Mingw. I am trying to make a multidimensional array of chars to contain what functions to patch.

I have checked for other questions about this and found one where the asker forgot to add commas to the end of every string literal, but I have done that already.

Could anyone help me?

The source that triggers the error:

char patches2[][64] = {
    "CreateMutexW",
    "CreateRemoteThread",
    "CreateRemoteThreadEx",
    "?strcmp@unicode_string_trait@esl@@SAJPB_W0@Z",
    "??0?$CStringT@_WVunicode_string_trait@esl@@Vunicode_string_implement@2@@esl@@QAE@XZ",
    "??0?$CStringT@_WVunicode_string_trait@esl@@Vunicode_string_implement@2@@esl@@QAE@PB_W@Z",
    "??4?$CStringT@_WVunicode_string_trait@esl@@Vunicode_string_implement@2@@esl@@QAEAAV01@PB_W@Z",
    "?GetContent@?$CStringT@_WVunicode_string_trait@esl@@Vunicode_string_implement@2@@esl@@QBEPB_WXZ",
    "?SetLookUpOrder@CFileSystem@esl@@QAEXW4EFileLookUpOrder@esl_constant@2@@Z",
    "??1package_file_item@esl@@QAE@XZ",
    "??1CFormatter@esl@@QAE@XZ",
    "??6CFormatter@esl@@QAEAAV01@K@Z",
    "??6CFormatter@esl@@QAEAAV01@G@Z",
    "??6CFormatter@esl@@QAEAAV01@M@Z",
    "??6CFormatter@esl@@QAEAAV01@PB_W@Z",
    "??BCFormatter@esl@@QBE?AV?$CStringT@_WVunicode_string_trait@esl@@Vunicode_string_implement@2@@1@XZ",
    "?__time@etc@esl@@YAKXZ",
    "?ReadFSAA@CGameOptionMgr@pleione@@QAE?AW4EFSAA@pleione_constant@2@XZ",
    "?ReadFSAAQuality@CGameOptionMgr@pleione@@QAEKXZ",
    "?CleanUp@CPleione@pleione@@QAE_NXZ",
    "?SetSkyTime@CAtmosphere@pleione@@QAEXM@Z",
    "?SetCamera@CCameraControl@pleione@@QAEXPAVCScene@2@PAVITerrain@2@KFF@Z",
    "?GetObjectId@CObject@mint@@QBE_KXZ",
    "?ReadU8@CMessage@mint@@QAEEXZ",
    "?GetLuck@IParameter@core@@QAEMXZ",
    "?GetGateLocalName@CGateMgr@core@@QBE?BV?$CStringT@_WVunicode_string_trait@esl@@Vunicode_string_implement@2@@esl@@AB v34@@Z",
    "?GetLife@IParameterBase2@core@@QAEMXZ",
    "?GetLifeMax@IParameterBase2@core@@QAEMXZ",
    "?IsEiry@SItemEgoInfo@@QBE_NXZ",
    "?SetFog@CDungeonRegion@core@@QAEX_N@Z",
    "?GetTargetCombatPower@ICharacter@core@@QAE?AW4ECombatPower@@PBname2@@Z",
    "?GetCombatPower@IParameterBase2@core@@QBEMXZ",
    "?GetInterfaceDurability@IItem@core@@QBEKXZ",
    "?GetInterfaceDurabilityMax@IItem@core@@QBEKXZ",
    "?GetColor@IItem@core@@QBEKK@Z",
    "?IsElf@ICharacter@core@@QBE_NXZ",
    "?IsGiant@ICharacter@core@@QBE_NXZ",
    "?IsPet@ICharacter@core@@QBE_NXZ",
    "?IsNPC@ICharacter@core@@QBE_NXZ",
    "?IsNamedNPC@ICharacter@core@@QBE_NXZ",
    "?IsGoodNPC@ICharacter@core@@QBE_NXZ",
    "?Compile@CDefaultCompiler@pleione@@UAEPAVCCompiledText@2@ABV?$CStringT@_WVunicode_string_trait@esl@@Vunicode_string_implement@2@@esl@@ABUtext_option@2@@Z",
    "?Compile@CDefaultTagCompiler@pleione@@UAEPAVCCompiledText@2@ABV?$CStringT@_WVunicode_string_trait@esl@@Vunicode_string_implement@2@@esl@@ABUtext_option@2@@Z",
    "?Compile@CHTMLCompiler@pleione@@UAEPAVCCompiledText@2@ABV?$CStringT@_WVunicode_string_trait@esl@@Vunicode_string_implement@2@@esl@@ABUtext_option@2@@Z",
    "?_RenderGlowOverlay@CRendererContext@pleione@@AAEXXZ",
    "?GetExploLevel@IParameterBase2@core@@QBEGXZ",
    "?GetExploExpPercent@IParameter@core@@QBEMXZ",
    "?ParseCommand@CUserConsoleMgr@core@@QBE_NABV?$CStringT@_WVunicode_string_trait@esl@@Vunicode_string_implement@2@@esl@@AAVCUserConsole@2@@Z",
    "?Instance@CLocalizer@core@@SAAAname2@XZ",
 开发者_运维百科   "?GetLocalText@CLocalizer@core@@QBE?AVCFormatter@esl@@ABV?$CStringT@_WVunicode_string_trait@esl@@Vunicode_string_implement@2@@4@@Z",
    "?stdapi_ShowChattingMessage@core@@YAX_KABV?$CStringT@_WVunicode_string_trait@esl@@Vunicode_string_implement@2@@esl@@1KKE@Z",
    "?stdapi_ShowCaption@core@@YAX_KABV?$CStringT@_WVunicode_string_trait@esl@@Vunicode_string_implement@2@@esl@@W4EMessageCaptionType@@KKK0@Z",
    "?stdapi_GetGlobalTime@core@@YA_KXZ",
    "?stdapi_GlobalTimeToGameTime@core@@YAX_KAAK11@Z",
    "?IsUsingNaosSupport@IServiceMgr@core@@QBE_NXZ",
    "?CheckFastStringID@IProp@core@@QBE_NPB_W@Z",
    "?IsUsableContents@IServiceMgr@core@@QBE_NW4EServiceContents@2@@Z",
    "?IsTransformed@ITransformMgr@core@@QBE_NXZ",
    "?GetFullSuitID@ICharacter@core@@QAEKXZ",
    "?IsBroken@IItem@core@@QBE_NXZ",
    "?CheckFastStringID@IItem@core@@QBE_NPB_W@Z",
    "?IsExpired@IItem@core@@QAE_N_K@Z",
    "?IsArenaField@IRegion@core@@QBE?B_NXZ",
    "?CanAttackTarget@IPVPMgr@core@@QBE_NPBVICharacter@2@@Z"
};


char patches2[][64]

This is an array of arrays. The first dimension is determined automatically from the number of elements in the initializer. The second dimension is specified as being 64 chars.

Some of the string literals with which you initialize patches2 are longer than 64 characters in length. You need to increase the size to some value large enough to hold the largest C string in the initializer.


Well, the declaration for a single string looks like this:

const char* myString = "MyString";

What you probably want is an array of const char*s. You can change char patches2[][64] to const char* patches2[] (an array of pointers to const char).

The number of const char*s in patches2 can be calculated using sizeof():

const char* patches2[] = {"CreateMutexW", /* The rest... */ };
int numPatches = sizeof(patches2) / sizeof(const char*);

So if you add/remove some strings, you don't have to update the dimensions.

0

精彩评论

暂无评论...
验证码 换一张
取 消