SA-MP Forums Archive
Macro causes loose identation warning - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Macro causes loose identation warning (/showthread.php?tid=626457)



Macro causes loose identation warning - BiosMarcel - 15.01.2017

Hey,

I have made myself a little Benchmarking macro recently, but it is causing loose identation warnings, which is quite annoying. I'd appreciate if someone could explain why that happens, here is the macro:

PHP код:
#define BENCHMARK(%0,%1,%2); \
    
{\
    new 
startTick GetTickCount();\
    for(new 
count 0count < %1count++)\
    {\
        %
0;\
    }\
    new 
endTick GetTickCount();\
    
printf("%s: %dms in %d iterations", %2endTick startTick, %1);\
    } 
If anyone wonders about the first and the last bracket, it is to prevent variable shadowing.

greetings marcel


Re: Macro causes loose identation warning - oMa37 - 15.01.2017

It works fine.

PHP код:
#define BENCHMARK(%0,%1,%2); \
    
{\
        new 
startTick GetTickCount();\
        for(new 
count 0count < %1count++)\
        {\
            %
0;\
        }\
        new 
endTick GetTickCount();\
        
printf("%s: %dms in %d iterations", %2endTick startTick, %1);\
    } 



Re: Macro causes loose identation warning - BiosMarcel - 15.01.2017

Nope, doesn't , still getting a warning.


Re: Macro causes loose identation warning - Lordzy - 15.01.2017

pawn Код:
#define BENCHMARK(%0,%1,%2) \
    new bnchmrkTick = GetTickCount(); \
    for(new bnchmrki = 0; bnchmrki < %1; bnchmrki++) { \
        %0; \
    } \
    printf("%s : %dms in %d iterations.", %2, GetTickCount() - bnchmrkTick, %1)
Haven't tested.


Re: Macro causes loose identation warning - BiosMarcel - 15.01.2017

Quote:
Originally Posted by Lordzy
Посмотреть сообщение
pawn Код:
#define BENCHMARK(%0,%1,%2) \
    new bnchmrkTick = GetTickCount(); \
    for(new bnchmrki = 0; bnchmrki < %1; bnchmrki++) { \
        %0; \
    } \
    printf("%s : %dms in %d iterations.", %2, GetTickCount() - bnchmrkTick, %1)
Haven't tested.
Still no ^^


Re: Macro causes loose identation warning - SyS - 15.01.2017

That's weird its not showing any warning to me.Are you using tabs or spaces to indent?


Re: Macro causes loose identation warning - BiosMarcel - 15.01.2017

Tabs, i also assured there are not spaces and the indentation is properly.

Edit:

Tried it with a clean script:

PHP код:
#include <a_samp>
#include <Development\DevTools>
main()
{
    
BENCHMARK(print("test"), 1"Test");

But still getting the warning


Re: Macro causes loose identation warning - Gammix - 15.01.2017

PHP код:
#define BENCHMARK(%0,%1,%2); \
    
{\
    new 
startTick GetTickCount();\
    for(new 
count 0count < %1count++) %0;\
    new 
endTick GetTickCount();\
    
printf("%s: %dms in %d iterations", %2endTick startTick, %1);\
    } 



Re: Macro causes loose identation warning - BiosMarcel - 15.01.2017

Quote:
Originally Posted by Gammix
Посмотреть сообщение
PHP код:
#define BENCHMARK(%0,%1,%2); \
    
{\
    new 
startTick GetTickCount();\
    for(new 
count 0count < %1count++) %0;\
    new 
endTick GetTickCount();\
    
printf("%s: %dms in %d iterations", %2endTick startTick, %1);\
    } 
This one works, so, was the for loop a problem? if yes, why?


Re: Macro causes loose identation warning - Gammix - 16.01.2017

Quote:
Originally Posted by [Bios]Marcel
Посмотреть сообщение
This one works, so, was the for loop a problem? if yes, why?
Its because no matter if you give tabs or spaces inside braces in macros, you get a warning.

Might be compiler bug!