473,398 Members | 2,525 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Stringizing

Hi,

I have this

#define KB 1
#define KB_AM 33
#define KB_RM 44
#define AM 2
#define RM 3

#define STR_KB 9
#define STR_AM 10
#define STR_RM 11
void map_fn( int config)
{

int temp;

switch(config) {
case KB:
case KB_AM:
case KB_RM:

if (config == KB)
fill_up (... , STR_KB);
else if (config == KB_AM
fill_up (... , STR_KB_AM);
else if (config == KB_RM)
fill_up (... , STR_KB_RM);
break;

case AM:
fill_up (..., STR_AM);
break;
}

How can i have a macro which based on the 'config value' pre-appends
'STR_' to it and
call fill_up() function.
Inside fill_up() it should give appropriate #defined values for
STR_KB/STR_KB_RM/...etc.

TIA
- Ravi

Nov 1 '06 #1
1 1927

On Wed, 1 Nov 2006, Ravi wrote:
>
I have this
[reformatted inline to conserve vertical space, and re-add indentation
omitted by the OP or by his newsreader]
#define KB 1
#define KB_AM 33
#define KB_RM 44
#define AM 2
#define RM 3

#define STR_KB 9
#define STR_AM 10
#define STR_RM 11
void map_fn(int config) {
int temp;
switch (config) {
case KB:
case KB_AM:
case KB_RM:
if (config == KB)
fill_up(... , STR_KB);
else if (config == KB_AM
fill_up(... , STR_KB_AM);
else if (config == KB_RM)
fill_up(... , STR_KB_RM);
break;
case AM:
fill_up(..., STR_AM);
break;
}

How can i have a macro which based on the 'config value' pre-appends
'STR_' to it and
call fill_up() function.
What's wrong with the straightforward approach?

#define FILLUP(x) fill_up(... , STR_##x)

-Arthur
Nov 1 '06 #2

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

Similar topics

2
by: Steven T. Hatton | last post by:
I'm serious about this folks! I really want to see the CPP obviated. People who have never used tools such as JBuilder may not fully appreciate the advantages they provide. This isn't about...
8
by: Siemel Naran | last post by:
#define EXPECT_ASSERT(x) { if (!x) expect_assert(localVariable, __FILE__, __LINE__, #x); } MSVC7 gives an error: "error C2014: preprocessor command must start as first nonwhite space".
14
by: Henry Townsend | last post by:
Consider the little program below. It simply attempts to determine what version of what compiler it was built with via documented preprocessor macros and print out the result. When the compiler is...
2
by: babakandme | last post by:
Hi everybody:D I've a string that contains the name of a class. Some members told that I can use """Stringizing Operator (#)""", but the problem is here, that I have the string, & I want...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
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
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,...
0
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...

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.