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

Any elegant way to do this?

P L
I have codes with blocks like this:

void h() {
..
..
..
a;
b1;
b2;
..
..
..
bn;
c;
..
..
..
}

and I need to change it to something like:

static void g()
{
b1;
b2;
..
..
..
bn;
}

void h() {
..
..
..
a;
#ifdef ABC
b1;
b2;
..
..
..
bn;
#else
f(g); /* f is some function taking g as arg */
#endif
c;
..
..
..

}

I don't like to copy the blocks because of two reasons: there are lot
of such changed need to be made; and any future changes in b1; ...; bn
will need changes in two places. I am reluctant to add a lot of
backslashes and put b1; ...; bn in a macro; and would prefer some
other elegant way. Also, I would prefer to keep the block of
statements themselves b1; ...; bn at their current places. I come up
with something like:

static void g();

void h() {
..
..
..
a;
#define BB \
b1; \
b2; \
.. \
.. \
.. \
bn;
#ifdef ABC
BB
#else
f(g);
#endif
c;
..
..
..

}

static void g() {BB}
#undef BB

But as I said earlier, I don't quite like the many extra backslashes.
Can someone shed some light? Thanks. - PL
Nov 13 '05 #1
1 1393
js******@yahoo.com (P L) wrote in
news:7f**************************@posting.google.c om:
I have codes with blocks like this:

[snip]

We saw your first post, please wait for a reply instead of posting the
same thing over and over. It can take days for someone to give you an
answer.

--
- Mark ->
--
Nov 13 '05 #2

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

Similar topics

5
by: steve | last post by:
Hi, In my script (phpnuke), whenever there is access to database, there is this line of code: message_die(GENERAL_ERROR, ’some error msg’, ’’, __LINE__, __FILE__, $sql); Is there a more...
6
by: Kamilche | last post by:
Is there a more elegant way to change the working directory of Python to the directory of the currently executing script, and add a folder called 'Shared' to the Python search path? This is what...
4
by: Tamir Khason | last post by:
How can I convert (elegant way) Collection to Array without looping and new instances. E.G: I want to add elements of one menu to other, so secondMenu.MenuItems.AddRange(firstMenu.MenuItems);...
8
by: Braky Wacky | last post by:
Hello, I have an ASP.NET webpage that uses an instance of System.Web.UI.HtmlControls.HtmlInputFile for uploading files to our server. I came across the documentation at MSDN for upping the...
28
by: Rob Cowie | last post by:
Hi all, I wish to generate a sequence of the form 'aaa', 'aab', aac'.... 'aba', 'abb', 'abc' etc. all the way to 'zzz'. How would you construct a generator to acheive this? A simple,...
18
by: _dee | last post by:
Question about best use of interfaces: Say there's a 'Master' class that needs to implement a few interfaces: class Master : I1, I2, I3 { } The actual code already exists in smaller...
32
by: r.z. | last post by:
class vector3 { public: union { float data; struct { float x, y, z; };
5
by: Helmut Jarausch | last post by:
Hi, I'm looking for an elegant solution to the following (quite common) problem: Given a string of substrings separated by white space, split this into tuple/list of elements. The problem...
3
by: Anonymous | last post by:
I want to be able to restrict the set of classes for which a template class can be instantiated (i.e enforce that all instantiation MUST be for classes taht derive from a base type BaseType). ...
12
by: Helmut Jarausch | last post by:
Hi, I'm looking for an elegant solution of the following tiny but common problem. I have a list of tuples (Unique_ID,Date) both of which are strings. I want to delete the tuple (element) with...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.