combining workspaces

H

hurry

I have two different set of codes (say A and B workspaces) I want to
call the entire B as a function inside A.I want a solution to do this.

To my knowledge, one soltn. would b to add all files of B in A's
workspace and compile like any other fnuction but, the pblm here is
both B and A are huge piles of codes and at many places happen have
same variables ( in their declaration in header). so, for this soltn.
to work, I`ll have to change all the variables in their headers and in
..C in B's workspace ( which is a HERCULIAN task, considering the
voluminosity of the codes).

Points here to be noted abt the program are:
1) A calls B in a loop and gives an input and needs an output.
2) B does not need to hold any variable betwn its entry (in other
words) shortly/vaguely, B does not need to have any static variables.

Is there a way like, when I call B the entire A's workspace goes behind
the screen and does not have any clashes betwn same variables decalred
in headers of A and B.

bye,
hurry.
 
R

Richard Heathfield

hurry said:
I have two different set of codes (say A and B workspaces) I want to
call the entire B as a function inside A.I want a solution to do this.

To my knowledge, one soltn. would b to add all files of B in A's
workspace and compile like any other fnuction but, the pblm here is
both B and A are huge piles of codes and at many places happen have
same variables ( in their declaration in header). so, for this soltn.
to work, I`ll have to change all the variables in their headers and in
.C in B's workspace ( which is a HERCULIAN task, considering the
voluminosity of the codes).

You just discovered why it's a good idea not to use file scope objects if
you can possibly avoid them - or at least to severely constrain them to
perhaps one or maybe two at most in each library.

I've been pointing this out in comp.lang.c, on and off, since 1999 or so.
You shoulda listened.
Points here to be noted abt the program are:
1) A calls B in a loop and gives an input and needs an output.
2) B does not need to hold any variable betwn its entry (in other
words) shortly/vaguely, B does not need to have any static variables.

Is there a way like, when I call B the entire A's workspace goes behind
the screen and does not have any clashes betwn same variables decalred
in headers of A and B.

You could make one colossal great source file out of all A's stuff, and make
all the extern objects static instead - very clumsy, and far from
guaranteed to work, especially if A relied implicitly on separation of
sources.

The real answer, as always, is "don't start from here". In other words, if
you'd paid attention to the nit-picking style pedants in the first place,
you wouldn't be in this mess now.
 
C

CBFalconer

Richard said:
hurry said:


You just discovered why it's a good idea not to use file scope
objects if you can possibly avoid them - or at least to severely
constrain them to perhaps one or maybe two at most in each library.

I've been pointing this out in comp.lang.c, on and off, since 1999
or so. You shoulda listened.

However, fear not. The little old toolmaker is here. Go thou and
download and use id2id-20, and the Augean stables may become a
kitty litter box.

<http://cbfalconer.home.att.net/download/id2id-20.zip>

Of course, if you had listened to Richard you wouldn't need it. As
it is you have to listen to the cackling sounds of "we told you
so".

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top