Error in macro
#1

Hello, I'm making function that will create string with lowest possible calculated index for the string (may save LITTLE amount of memory ). You can too format this string inside function, but I have problem getting error:
error 001: expected token: "-string end-"

pawn Код:
DeclareOptimiziedString("string", "Hello %s!", "Jack"); //Example usage -> this string should have 14 cells which is lowest possible

//Macro
#define DeclareOptimiziedString(%0,%1,%2) \
        new %0[IndexCount(%1, %2)] \
        format(%0, sizeof(%0), %1, %2);

//Func that calculates index of string (with format)
IndexCount(const src[], const fmat[])
{
    new
        count,
        i;

    while(i++ < strlen(fmat))
    {
     
        if(fmat[i] == '"' || fmat[i] == ',' || fmat[i] == 32)
        {
            continue;
        }
        count++;
    }
    return strlen(src) + count;
}
Thanks!
Reply


Messages In This Thread
Error in macro - by Riwerry - 12.08.2014, 17:19
Re: Error in macro - by Vince - 12.08.2014, 18:13
Re: Error in macro - by Riwerry - 12.08.2014, 18:33
Re: Error in macro - by [XST]O_x - 12.08.2014, 18:37
Re: Error in macro - by Riwerry - 12.08.2014, 18:49

Forum Jump:


Users browsing this thread: 1 Guest(s)