473,396 Members | 1,758 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,396 software developers and data experts.

Question about many #define

#define PIC1 "pic1.gif"
#define PIC2 "pic2.gif"
:
:
#define PIC999 "pic999.gif"

any shortcut/trick/preprocessor directive/operator can do above easily?

thanks.
rgds.
alan
--END
Jul 22 '05 #1
3 1205
On Sat, 18 Sep 2004 01:15:39 -0700, Alan Pong wrote:
#define PIC1 "pic1.gif"
#define PIC2 "pic2.gif"
:
:
#define PIC999 "pic999.gif"

any shortcut/trick/preprocessor directive/operator can do above easily?


What are you really trying to do? What is the problem the above is
attempting to solve?

// Untested, and my macro-fu is seriously weak
#define PIC(x) "pic" #x ".gif"

// Unsure of efficiency of ostringstream, but otherwise better, IMO
#include <string>
#include <sstream>

inline
std::string pic(int x) {
std::ostringstream buffer;
buffer << "pic" << x << ".gif";
return buffer.str ();
}

--
Some say the Wired doesn't have political borders like the real world,
but there are far too many nonsense-spouting anarchists or idiots who
think that pranks are a revolution.

Jul 22 '05 #2
Alan Pong wrote:
#define PIC1 "pic1.gif"
#define PIC2 "pic2.gif"
:
:
#define PIC999 "pic999.gif"

any shortcut/trick/preprocessor directive/operator can do above easily?


Write a program that write it.

But I wonder why you need to do that.

--
Salu2
Jul 22 '05 #3
In article <ea**************************@posting.google.com >,
Alan Pong <al******@hkstar.com> wrote:
#define PIC1 "pic1.gif"
#define PIC2 "pic2.gif"
:
:
#define PIC999 "pic999.gif"

any shortcut/trick/preprocessor directive/operator can do above easily?


You can probably ease it with the preprocessor string'izing operator
(google that) but this leads to the question of "What are you trying
to ease?" That is, why do you need so many define's? How is
it better than just keeping track of some int? Etc.
--
Greg Comeau / Comeau C++ 4.3.3, for C++03 core language support
Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Jul 22 '05 #4

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

Similar topics

11
by: Dmitry D | last post by:
Hi, I'm new to C++ (started learning in the beginning of this summer), and I have the following question (sorry if it sounds stupid): In many code samples and source files, I see NULL expression...
9
by: Dave H | last post by:
Hello, I have a query regarding definition lists. Is it good practice semantically to use the dt and dd elements to mark up questions and answers in a frequently asked questions list, or FAQ? ...
1
by: Dan W. | last post by:
I've been acting as messenger the past few days between the BOOST and Digital Mars peoples, and they can't seem to come to an agreement about the semantics of using ## vs. juxtaposition. The...
9
by: Rafi Kfir | last post by:
Hi, This may look as a smiple task to most of you, but to me (a beginner with C), it drives me crazy. All I want is that one function passes a two dimensional array of strings to another...
10
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...
90
by: John Salerno | last post by:
I'm a little confused. Why doesn't s evaluate to True in the first part, but it does in the second? Is the first statement something different? False print 'hi' hi Thanks.
3
by: Jeff Kish | last post by:
It's been a while since I had to delve into this topic, and I hope this is a good place for this question. I don't know much about schemas, probably a bit more about dtd's. I have a system that...
6
by: damiensawyer | last post by:
Hi, Can someone please explain to me something about delegates? My understanding is as follows. A delegate is basically an object that can hold a reference to a "method" somewhere. That is,...
9
by: Peskov Dmitry | last post by:
It is a very basic question.Surely i got something wrong in my basic understanding. //Contents of file1.cpp using namespace std; #include <iostream> template <typename T> class my_stack;
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.