By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,009 Members | 1,487 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,009 IT Pros & Developers. It's quick & easy.

Functions inside Macro Curly brace

P: n/a
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);

Apr 24 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
* 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.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Apr 24 '06 #2

P: n/a
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.

Alf P. Steinbach wrote:
* 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.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?


Apr 24 '06 #3

P: n/a
* 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.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Apr 24 '06 #4

P: n/a
krbyxtrm wrote:
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!

--
Phlip
http://www.greencheese.org/ZeekLand <-- NOT a blog!!!
Apr 24 '06 #5

P: n/a


Thanks anyways.
Ayon kay Phlip:
krbyxtrm wrote:
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!

--
Phlip
http://www.greencheese.org/ZeekLand <-- NOT a blog!!!


Apr 24 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.