Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Any elegant way to do this?

Reply
Thread Tools

Any elegant way to do this?

 
 
P L
Guest
Posts: n/a
 
      10-17-2003
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
 
Reply With Quote
 
 
 
 
Mark A. Odell
Guest
Posts: n/a
 
      10-17-2003
http://www.velocityreviews.com/forums/(E-Mail Removed) (P L) wrote in
news:(E-Mail Removed) 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 ->
--
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Any elegant way to construct the complete $k$-partite graph inPython? Paul Miller Python 6 11-24-2009 01:02 PM
501 PIX "deny any any" "allow any any" Any Anybody? Networking Student Cisco 4 11-16-2006 10:40 PM
Any convenient and elegant way to do encoding conversion in C++? Licheng Fang C++ 5 09-23-2006 04:09 PM
Any elegant way of doing this? Morten Wennevik ASP .Net 4 11-08-2005 03:00 PM
Re: Is there an elegant way to set an unsigned vector to 1 Jan De Ceuster VHDL 5 01-13-2005 07:26 AM



Advertisments