Functions inside Macro Curly brace

K

krbyxtrm

Hi

is there a way to 'manage' function execution using macros?

#define MY_CALL_MACRO(MacroName)
{ g_MacroStack.push_back(MacroName);
<some code here...>}

such that when i use the macro like this:
MY_CALL_MACRO("MyMacroName")
{
Func1(123);
Func2(1);
Func3(1,123);
}

MY_CALL_MACRO("YetAnotherMacro")
{
Func2(1); // will be tagged with 1
Func3(1,123); // will be tagged with 2
}

I have a choice which Function in MyMacroName macro will be called,
functions inside the curly braces?

e.g.

CallFunctionByMacro(const char* szMacro, UINT function);
 
A

Alf P. Steinbach

* krbyxtrm:
is there a way to 'manage' function execution using macros?
Yes.


#define MY_CALL_MACRO(MacroName)

Here endeth the macro definition.

{ g_MacroStack.push_back(MacroName);
<some code here...>}

Braces have no special meaning in macro definitions; they're just
braces, as usual.

However, here they're not even part of the definition.

such that when i use the macro like this:
MY_CALL_MACRO("MyMacroName")
{
Func1(123);
Func2(1);
Func3(1,123);
}

MY_CALL_MACRO("YetAnotherMacro")
{
Func2(1); // will be tagged with 1
Func3(1,123); // will be tagged with 2
}

I have a choice which Function in MyMacroName macro will be called,
functions inside the curly braces?

e.g.

CallFunctionByMacro(const char* szMacro, UINT function);

The question doesn't make sense.

It's possible that what you want is to perform one of n different
actions depending on a value determined at run time; for that you might
look up the command pattern.

If you'd like a more precise or directly useful answer please indicate
/what/ it is you'd like to achieve, in context, not the context free
/how/ details of some imaginary scheme to implement that effect.
 
K

krbyxtrm

Using some *schemes* i have been able to achieve what you call schemes,
but in a very different way, away from C++ programming styles, so in
turn i tried to ask some people how to implement such in C++ MACRO
style.

As a summary:
I need to be able know all the functions within the MACRO braces such
that later i will call any of the functions there.

The reason i talked about MACRO is that i've seen such methods:
functions tagged and called in reference of the MACRO name from a
Vendor-Specific programming library (DLL) And its undocumented.
 
A

Alf P. Steinbach

* krbyxtrm:
> [top-posting, quoting signature]

Please don't top-post in this group; see this group's FAQ.

And please don't quote signatures or other extranous material.
 
P

Phlip

krbyxtrm said:
Using some *schemes* i have been able to achieve what you call schemes,
but in a very different way, away from C++ programming styles, so in
turn i tried to ask some people how to implement such in C++ MACRO
style.

As a summary:
I need to be able know all the functions within the MACRO braces such
that later i will call any of the functions there.

The reason i talked about MACRO is that i've seen such methods:
functions tagged and called in reference of the MACRO name from a
Vendor-Specific programming library (DLL) And its undocumented.

That's a description of a solution. What is the problem you think it will
solve? Please post a code sample of that problem!
 
K

krbyxtrm

Thanks anyways.


Ayon kay Phlip:
That's a description of a solution. What is the problem you think it will
solve? Please post a code sample of that problem!
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top