Macro causes loose identation warning
#1

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
Reply
#2

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);\
    } 
Reply
#3

Nope, doesn't , still getting a warning.
Reply
#4

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.
Reply
#5

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 ^^
Reply
#6

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

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
Reply
#8

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);\
    } 
Reply
#9

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?
Reply
#10

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!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)