Posted By: sheefo
Useful Macros - 08/17/07 14:34
I was thinking, perhaps people can post some useful macros definitions here so we can have a collection for everyone to benefit from.
Here is one I came up with, since I found out about using tokens in macros.
It is so much better than using "malloc(sizeof(type))", and in VC++ it is highlighter
See below:
MACRO:
Code:
USE:
Code:
Now it's your turn...
Here is one I came up with, since I found out about using tokens in macros.
It is so much better than using "malloc(sizeof(type))", and in VC++ it is highlighter
See below:
MACRO:
Code:
#define new(type) malloc(sizeof(type##))
#define delete(object) free(object)
USE:
Code:
// Create new object like this...
int *myint = new(int);
// ...Instead of like this.
int *myint = (int*)malloc(sizeof(int));
...
// Lookes better than 'free'
delete(myint);
Now it's your turn...