Problem With Macros

> Hi All,

I am having some problem with Macros. I will try to explain it with
a example.

There is a macro “errno” in stddef.h which is a standard include file
provided with microsoft. The problem comes when I want to define my own
version of “errno”. For this I defined “#undef errno” but until this
#undef gets executed, the old version of “errno” in stddef.h is compiled.
Hence I have two version of “errno” in my project. What project setting I
have to modify so that MY definition of “errno” is used for all files in
the project ?
Thanks in Advance
KD

First errno is not a macro, its a variable.
The easiest way to solve this is to define your own macro say #define
MY_errno, and change each occurrences of errno in your project files to
MY_errno.
By doing this it allows you to choose the default version or your version of
the errno behavior…
#ifdef USE_DEFAULT_ERRNO
#define MY_errno errno
#else
#define MY_errno … //your version of errno
#endif

In general don’t mess around with the variables defined in the default
include files, you may end up in more problem at a later time.

Regards,
Manoj

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Kd_Kaliannan
Sent: Tuesday, March 14, 2000 3:06 PM
To: NT Developers Interest List
Subject: [ntdev] Problem With Macros
Importance: High
Sensitivity: Personal

Hi All,
I am having some problem with Macros. I will try to explain it with
a example.
There is a macro “errno” in stddef.h which is a standard include file
provided with microsoft. The problem comes when I want to define my own
version of “errno”. For this I defined “#undef errno” but until this #undef
gets executed, the old version of “errno” in stddef.h is compiled. Hence I
have two version of “errno” in my project. What project setting I have to
modify so that MY definition of “errno” is used for all files in the project
?
Thanks in Advance
KD