Preprocessor macro substitution

D

Default User

I've never really done too much stuff with macros. I have a program
here where an target server address is automatically generated from
WSDL. For testing, I want to use a localhost address.

I could do it by overriding the endpoint explicitly, but I'd rather
not. It would be cleaner to define a local testing environment.

My first thought was just to use a #define, like:

#define foo.bar localhost

However, that's no good as foo.bar tain't a legal identifier with that
'.' in it. Anyone have some clever preprocessor way to get what I want?





Brian
 
D

Default User

Eric said:
What you haven't told us is where you're starting: How do
you get hold of the server address to begin with? "From WSDL"
doesn't seem to me a very complete description ...

I didn't want to get too deeply into the details, but evidently I was
insufficiently thorough. The service address is specified in the WSDL.
A utility processes this and generates some C headers and source files.
Included in some places is the "endpoint" or target address. If you
don't provide an overriding address, then this is the one that is used.
So there will things like this:

if (!soap_endpoint)
soap_endpoint = "http://foo.bar:8080"

As it is generated code, I can't change that. I can provide an
endpoint, but that's fragile, as it then requires a manual update if
the WSDL is changed.

I can also do something like:

soap_endpoint = END_POINT;

Then for testing purposes:

#ifdef TESTING
#define END_POINT "http://localhost:8080"
#else
#define END_POINT NULL
#end



It's not as clean, but would work.



Brian
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top