 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
iwl Guest
|
Posted: Mon Dec 18, 2006 5:47 pm Post subject: HOWTO: #define macro m(x,y,...) funcxyz(x,y,...) ??? |
|
|
Hi,
can I define a macro with variable Parameters for calling such funcs
#define macro m(x, y, ...) funcxyz(x, y, ...) ???? |
|
| Back to top |
|
 |
Alan Bellingham Guest
|
Posted: Mon Dec 18, 2006 5:52 pm Post subject: Re: HOWTO: #define macro m(x,y,...) funcxyz(x,y,...) ??? |
|
|
"iwl" <Ingo.Wolf (AT) gmx (DOT) de> wrote:
| Quote: | can I define a macro with variable Parameters for calling such funcs
#define macro m(x, y, ...) funcxyz(x, y, ...) ????
|
#define m funcxyz
is about the best you can do. macros are dumb text-replacement tools,
not something very sophisticated. They're certainly not a real
metaprogramming tool as you get in some languages.
Alan Bellingham
--
ACCU Conference: 11-14 April 2007 - Paramount Oxford Hotel |
|
| Back to top |
|
 |
Chris Uzdavinis (TeamB) Guest
|
Posted: Mon Dec 18, 2006 9:14 pm Post subject: Re: HOWTO: #define macro m(x,y,...) funcxyz(x,y,...) ??? |
|
|
"iwl" <Ingo.Wolf (AT) gmx (DOT) de> writes:
| Quote: | Hi,
can I define a macro with variable Parameters for calling such funcs
#define macro m(x, y, ...) funcxyz(x, y, ...) ????
|
Sorry, that is not possible. However, I believe the feature (added to
C99) was accepted for inclusion in a future version of C++, probably
not until 2009 or later, though. (But some vendors may jump the gun
and implement it early... who knows... though using such features have
a little risk, as the final version of the next C++ standard may
change along the way, and if you are using the "old" definition of a
specified feature, it may break when the compiler is brought into
compliance with the change.)
--
Chris (TeamB); |
|
| Back to top |
|
 |
Richard Guest
|
Posted: Tue Dec 26, 2006 4:25 am Post subject: Re: HOWTO: #define macro m(x,y,...) funcxyz(x,y,...) ??? |
|
|
Gee, I must be missing the big picture, because the code below seems to
works just fine.
Richard
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
#define FunctionCall_MACRO(X, Y) abc(X, Y)
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
int abc(int x, int y)
{
int z = x + y;
return z;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1_OnClick(TObject *Sender)
{
int z = FunctionCall_MACRO_MACRO(1,2);
}
//---------------------------------------------------------------------------
"Chris Uzdavinis (TeamB)" <chris (AT) uzdavinis (DOT) com> wrote in message
news:86r6uxw80l.fsf (AT) explicit (DOT) atdesk.com...
| Quote: | "iwl" <Ingo.Wolf (AT) gmx (DOT) de> writes:
Hi,
can I define a macro with variable Parameters for calling such funcs
#define macro m(x, y, ...) funcxyz(x, y, ...) ????
Sorry, that is not possible. However, I believe the feature (added to
C99) was accepted for inclusion in a future version of C++, probably
not until 2009 or later, though. (But some vendors may jump the gun
and implement it early... who knows... though using such features have
a little risk, as the final version of the next C++ standard may
change along the way, and if you are using the "old" definition of a
specified feature, it may break when the compiler is brought into
compliance with the change.)
--
Chris (TeamB); |
|
|
| Back to top |
|
 |
Alan Bellingham Guest
|
Posted: Tue Dec 26, 2006 5:36 am Post subject: Re: HOWTO: #define macro m(x,y,...) funcxyz(x,y,...) ??? |
|
|
"Richard" <pecena (AT) cox (DOT) net> wrote:
| Quote: | Gee, I must be missing the big picture, because the code below seems to
works just fine.
|
[snip]
| Quote: | #define FunctionCall_MACRO(X, Y) abc(X, Y)
|
Well, yes, you are missing the big picture.
You may notice a '...' in the title of this thread that is mysteriously
completely missing from your version.
Alan Bellingham
--
Team Thai Kingdom
<url:http://www.borland.com/newsgroups/> Borland newsgroup descriptions
<url:http://www.borland.com/newsgroups/netiquette.html> netiquette |
|
| Back to top |
|
 |
Duane Hebert Guest
|
Posted: Tue Dec 26, 2006 6:27 am Post subject: Re: HOWTO: #define macro m(x,y,...) funcxyz(x,y,...) ??? |
|
|
"Richard" <pecena (AT) cox (DOT) net> wrote in message
news:45904fa0$2 (AT) newsgroups (DOT) borland.com...
| Quote: | Gee, I must be missing the big picture, because the code below seems to
works just fine.
|
I think you missed the ,... bit of m(x,y,...). |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|