J
JKop
I was doing some Win32 programming today, having to include the file
"windows.h". Anyway, I'm thinking of writing a program that'll work like so:
macrodestroyer.exe windows.h
What this program will do is scour through the file, replacing all macros
with global const variables and inline functions. So for instance, if you
have:
#define MAX_LOADSTRING 100
It'll become:
unsigned const MAX_LOADSTRING = 100;
And if you have:
#define Minus5(t) (t-5)
Then'd be turned into
template <class T,class R>
inline T Minus5(R r)
{
return (t-5);
}
Or something along those lines.
Anyway...
The main benefits of this would be:
A) Follows scoping rules, and you could wrap "windows.h" in a namespace, eg:
namespace Win { #include "windows.h" }
B) You wouldn't have the problem of:
SomeMacro(++i);
in that it may increment it more than once.
Also, I would turn:
#define LRESULT long;
into:
typdef long LRESULT;
Anyway, before I get going on this little pet project, has this been done
before?
Any ideas, comments at all?
-JKop
"windows.h". Anyway, I'm thinking of writing a program that'll work like so:
macrodestroyer.exe windows.h
What this program will do is scour through the file, replacing all macros
with global const variables and inline functions. So for instance, if you
have:
#define MAX_LOADSTRING 100
It'll become:
unsigned const MAX_LOADSTRING = 100;
And if you have:
#define Minus5(t) (t-5)
Then'd be turned into
template <class T,class R>
inline T Minus5(R r)
{
return (t-5);
}
Or something along those lines.
Anyway...
The main benefits of this would be:
A) Follows scoping rules, and you could wrap "windows.h" in a namespace, eg:
namespace Win { #include "windows.h" }
B) You wouldn't have the problem of:
SomeMacro(++i);
in that it may increment it more than once.
Also, I would turn:
#define LRESULT long;
into:
typdef long LRESULT;
Anyway, before I get going on this little pet project, has this been done
before?
Any ideas, comments at all?
-JKop