[Tool/Web/Other] The Pawn Community Compiler Project
#17

Is this a normal behavior of const-correctness? The compiler complains (as it should) about 1D array but not for 2D, 3D or 4D arrays
pawn Код:
#include <a_samp>

main()
{
    new arr[10];

    func(arr);

    printf("value: %d", arr[0]);
}

func(const arr[])
{
    arr[0] = 1; // error 022: must be lvalue (non-constant)
}
pawn Код:
#include <a_samp>

main()
{
    new arr[10][10];

    func(arr);

    printf("value: %d", arr[0][0]); // prints "value: 1"
}

func(const arr[][])
{
    arr[0][0] = 1;
}
No warnings. It modifies the value even though it is meant to be a constant array.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)