Closed A1mDev closed 3 months ago
hrm... seems like working as-is? const is transitive, and you're discarding const by passing to Foo().
I just passed this const char[] to the sourcemod function, I can’t fix the built-in functions in the sourcemod, that’s why this question arose.
static const char sSurvivorsNames[][] = {"Nick", "Rochelle", "Coach", "Ellis"};
public void OnPluginStart()
{
//CheatCommand(int client, char[] command, char[] arguments = "")
CheatCommand(0, "sb_add", sSurvivorsNames[0])
}
Is CheatCommand a SourceMod function? If so, let's move this bug there and fix it there.
Oops, I was wrong about this function, but I think we can find another function without the const keyword.
I still have a question, why it is impossible to declare a constant in the global scope without keywords public, stock, static. Example:
// public const char sSurvivorsNames[][] = {"Nick", "Rochelle", "Coach", "Ellis"};
// static const char sSurvivorsNames[][] = {"Nick", "Rochelle", "Coach", "Ellis"};
// stock const char sSurvivorsNames[][] = {"Nick", "Rochelle", "Coach", "Ellis"};
const char sSurvivorsNames[][] = {"Nick", "Rochelle", "Coach", "Ellis"};
public void OnPluginStart() {}
Hate is a strong word, and thus, the perfect word to describe my feelings toward "const". If I had a do-over I'd have removed it from SourcePawn on day 1.
Anyway, the reason it's not possible is just a quirk in the parser. It'd be pretty easy to fix, but... what's the point? const isn't helping you anywhere.
https://steamuserimages-a.akamaihd.net/ugc/2470858270604655082/FC99F271EF3D23E613F30E17C1792BA7D5E95E64/
I don't know if this should be the case, now the compiler complains about passing a const char[] parameter instead of char[]
Test code: