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 = 0; count < %1; count++)\
{\
%0;\
}\
new endTick = GetTickCount();\
printf("%s: %dms in %d iterations", %2, endTick - 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 = 0; count < %1; count++)\
{\
%0;\
}\
new endTick = GetTickCount();\
printf("%s: %dms in %d iterations", %2, endTick - 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 = 0; count < %1; count++) %0;\
new endTick = GetTickCount();\
printf("%s: %dms in %d iterations", %2, endTick - 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 = 0; count < %1; count++) %0;\
new endTick = GetTickCount();\
printf("%s: %dms in %d iterations", %2, endTick - 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!