- Fixing the warnings will save you hours of debugging.
- A bool only has the value zero or one. Doing bitwise operations on that is moronic.
1. Fixing the warnings makes my code less readable.
2. I am not doing bitwise on bool but inside if statement.
Example:
if
( flag & 0x00010011 ) // warning
if ( (bool)(flag & 0x0001001) ) // no warning
Of course, it gives a warning, you have if(int) which make no sense. Perhaps you want if( int != 0 )
I want if(int) without need for explicit casting int to bool.
My problem is:
- implicit conversion throws warnings (which I don't want)
- explicit conversion makes code less
readable (which I don't want)
Thats why I need directive to disable compiler warnings for the block of code where my bitwise operations
are.
To keep operations implicit and terminal logs clean.
After all I just made macro IF(x) if((bool)(x))
@William Roeder gave you the answer. I will spell it out:
#property strict #define IF(x) if((x) != 0) void OnStart() { int flag = 0x00010011; IF(flag & 0x00010011) { Print("yes"); } }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
is any preprocessor directive available for compiler to not throw warnings?
I made kind of library with bitwise operations and compiler throws 120 warnings because bool type is expected. I could cast to bool explicitly but the code becomes much less readable. If there is any way to disable compiler warnings for desired block of code I would be very happy to hear about it. I don't want people to receive 120 garbage warnings in they terminal right after #include my lib.