Unfortunately, macro names have to start with a letter or some subset of other characters (like '_') - '{' and '}' aren't in the valid set of characters.
The other problem with using the macro (if you did find a way) is that '{' and '}' occur in places other than function definitions:
typedef struct _Coord{ int x; int y;} Coord;Coord coords [] ={ {0, 0}, {0, 1}, {1, 1}, {1, 0}};
so the idea of replacing '{' and '}' would bugger the above code big time and the following code wouldn't be quite right either:
void function (void){ for (int i = 0 ; i < 10 ; ++i) { // you wouldn't want your stack check here // do something }}
Is there an alternative?
I can think of two possibilities: write your own preprocessor to replace the '{' and '}' that enclose functions with the stack check code. This is not compiler specific.
The other method is compiler specific and that's to define function hooks. Using MSVC V6, this is enabled by specifing /Gh on the compiler command line (you need professional or enterprise version for this). You then create a function called __penter which is then called at the start of every function. It doesn't have the name of the function or even any access to it, but you can get the address of the function and then compare that with the map file. There's no function to catch the end of the function though, but, with a bit of jiggery-pokery of the stack you can catch the return - provided you've not got any Pascal style functions.
Skizz