sourcepawn icon indicating copy to clipboard operation
sourcepawn copied to clipboard

too many unexpected loose indentation warnings for marcos

Open kice opened this issue 3 years ago • 1 comments

I just don't know why I got loose indentation warnings here. I have some fairly complicated marcos and it generate way too many "loose indentation" warnings when compile even I only space in my code.

I am pretty sure it is caused by if/else block.

If it is not fixable, maybe allow use #pragma to disable/re-enable certain warning?

#include <sourcemod>

#define __TEST(%1) \
    if (%1) { \ 
        PrintToServer("test"); \
    } \
    if (!(%1)) { \
        PrintToServer("!test"); \
    } \
    PrintToServer("__TEST");

public void Func()
{
    bool test = false;
    __TEST(test)
}

P.S. If we have inline functions then I could reduce some of my marco :P

kice avatar Jan 26 '21 14:01 kice

The preferred solution here is to use a normal function. This kind of macro is discouraged.

dvander avatar Jan 26 '21 23:01 dvander