#define SOME_CONSTANT 10
int main()
{
// Compiles to 'int 10 = 10', I believe
int SOME_CONSTANT = 10;
}
This is what happens:
main.cpp: In function 'int main()':
main.cpp:5:23: error: expected unqualified-id before numeric constant
#define SOME_CONSTANT 10
^
main.cpp:9:9: note: in expansion of macro 'SOME_CONSTANT'
int SOME_CONSTANT = 10;
Have fun debugging that in production code.
This is why we don't use #define anymore kids
Or maybe even better, some beginner decides to do this instead:
#define SOME_CONSTANT 10
int main()
{
// Compiles to 'int 10 = 10', I believe
SOME_CONSTANT = 10
}
And ends up with this:
main.cpp: In function 'int main()':
main.cpp:10:19: error: lvalue required as left operand of assignment
SOME_CONSTANT = 10
^
Of course, with .NET 4.5+ you have the MethodImplOptions.AggressiveInlining which helps with this issue.
So now you can do: [MethodImpl(MethodImplOptions.AggressiveInlining)] on a method which will attempt to inline the method implementation wherever possible.
@EBrown Some IDEs do things like this where they will purposely set #define DEBUG ... when you are using the debug function of the IDE in the case that you need to do something different with your code.