473,396 Members | 1,789 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Functions inside Macro Curly brace

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
5 3548
* 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
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
* 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
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


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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: deko | last post by:
Do I need to use curly brackets in PHP if .. else statements? other constructs? Does it matter? What are Best Practices? Why? thanks in advance... This seems to work WITHOUT curly brackets:...
1
by: Jeff | last post by:
Hello everybody, I have a question concerning function declarations. When exactly do you have to declare functions if you want to use them? I have two functions main() and foo(), respectively...
4
by: JavaGeekRoyR | last post by:
Hello all.. In the VS.Net IDE, is there a way to auto-format your code (such that the curly braces for code blocks automatically align, code is automatically indented to proper levels etc)? If...
4
by: Jason Kendall | last post by:
How do I use a curly brace within a string passed to String.Format? I want to pass a string that includes a curly brace, but that curly brace is not being used to indicate a replacable format...
23
by: Anil Gupte | last post by:
I am trying to set up a function that connects to the database that I can then use gloablly. I set up a class called L3Global in which I have a function as follows: Public Function...
5
by: TJ | last post by:
I'd like to know how the preprocessor treats curly braces, as compared to how it treats parentheses. What happens if I pass this: { a_function( arg1, arg2, arg3 ) } as an argument to a...
4
by: subramanian100in | last post by:
Consider the program #include <iostream> using namespace std; class Test { public: Test(Test_int c_value)
2
by: talkaboutquality | last post by:
Need to define a macro as, say, #ifdef NEED_FUNCTION foo(x) #else #endif
33
by: Peng Yu | last post by:
Hi, __PRETTY_FUNCTION__ is a macro that gives function name, etc. I'm wondering if there is a macro to get the class name inside a member function. Thanks, Peng
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.