473,500 Members | 1,865 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

conditional compilation

Hi

I need to create an object of her_t OR his_t inside a namespace. the
choice should be decided based on a macro. did the following
accomplish this?

thank you.

// macro
// uncomment ONLY ONE of the 2 lines below
#define HIS
//#define HER
namespace s_inf
{
....

#ifdef HIS
his_t conn; // FXGame OR FXTrade
#endif

#ifdef HER
her_t conn;
#endif

....
}

the above created his_t and NOT her_t object. right?

// place in a ".h" file and #include it in ".cpp" file and use the
object "conn".

Oct 26 '06 #1
3 1283
Leo
Yeah, It will.
When you start compiling, your code is done.
Gary Wessle wrote:
Hi

I need to create an object of her_t OR his_t inside a namespace. the
choice should be decided based on a macro. did the following
accomplish this?

thank you.

// macro
// uncomment ONLY ONE of the 2 lines below
#define HIS
//#define HER
namespace s_inf
{
...

#ifdef HIS
his_t conn; // FXGame OR FXTrade
#endif

#ifdef HER
her_t conn;
#endif

...
}

the above created his_t and NOT her_t object. right?

// place in a ".h" file and #include it in ".cpp" file and use the
object "conn".
Oct 26 '06 #2
Gary Wessle posted:
I need to create an object of her_t OR his_t inside a namespace. the
choice should be decided based on a macro.

#ifdef MALE
typedef his_t Type;
#else
#ifdef FEMALE
typedef her_t Type;
#else
#error "You must #define either MALE or FEMALE."
#endif
#endif

namespace MyNa {

Type obj;
}

--

Frederick Gotham
Oct 26 '06 #3
Frederick Gotham wrote:
Gary Wessle posted:
>I need to create an object of her_t OR his_t inside a namespace. the
choice should be decided based on a macro.


#ifdef MALE
typedef his_t Type;
#else
#ifdef FEMALE
typedef her_t Type;
#else
#error "You must #define either MALE or FEMALE."
#endif
#endif

namespace MyNa {

Type obj;
}
#if defined(MALE)
typedef his_t Type;
#elif defined(FEMALE)
typedef her_t Type;
#else
#error "You must #define either MALE or FEMALE
#endif
Oct 26 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
2439
by: Steven T. Hatton | last post by:
I've made no secret of the fact that I really dislike the C preprocessor in C++. No aspect of the language has caused me more trouble. No aspect of the language has cause more code I've read to be...
2
4300
by: Steve Jorgensen | last post by:
To begin with an example... Let's say you were wanting to write code usign early binding to the MSXML library, but then be able to switch between early and late binding at will. Conditional...
1
16528
by: chris han | last post by:
Hi, all, I'm trying to use Conditional Compilation Statements in my code. using System; #define DEBUG public class MyClass { public static void Main() {
12
2459
by: wanghz | last post by:
Hi, Could I ask some questions about the conditional compilaion? Suppose I have three simple files: a.c, b.c and c.h /* --------a.c--------- */ #include <stdio.h> #include "c.h" int...
2
2569
by: FireStarter | last post by:
Guys, in the code that follows, why does the method F() still compile, even if DBG is undefined? Inside method G(), the code inside <#if DBG> does not compile (notice that I can write whatever I...
1
3309
by: A.M-SG | last post by:
Hi, We have a solution with several c# projects within it. How can I define solution wide conditional compilation symbols?
4
2790
by: Bob | last post by:
Hi, In VS2003 conditional compilation constants and their state could be defined at project level. I was using this to control what features where offered by various builds. i.e....
10
3068
by: Dave | last post by:
I'm a C++ programmer of many years, trying to get my feet wet in C#. I have a question about conditional compilation. In C++, I would sometimes define a constant in an include file, and then...
1
2274
by: Marek | last post by:
I use VS2005 with framework 2.0 and I just found a behavior I consider odd. Here is the code that illustrates th eproblem: public static void MethodA() { MethodB() } #if DEBUG
6
2828
by: maxwell | last post by:
I'm trying to use the gpp utility (Gnu points to http://en.nothingisreal.com/wiki/GPP) to do conditional compilation in Python, and I'm running into a problem: the same '#' character introduces...
0
7018
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7182
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7232
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7397
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5490
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4923
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4611
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3110
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1430
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.