BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

HOWTO: #define macro m(x,y,...) funcxyz(x,y,...) ???

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language C++)
View previous topic :: View next topic  
Author Message
iwl
Guest





PostPosted: Mon Dec 18, 2006 5:47 pm    Post subject: HOWTO: #define macro m(x,y,...) funcxyz(x,y,...) ??? Reply with quote



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





PostPosted: Mon Dec 18, 2006 5:52 pm    Post subject: Re: HOWTO: #define macro m(x,y,...) funcxyz(x,y,...) ??? Reply with quote



"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





PostPosted: Mon Dec 18, 2006 9:14 pm    Post subject: Re: HOWTO: #define macro m(x,y,...) funcxyz(x,y,...) ??? Reply with quote



"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





PostPosted: Tue Dec 26, 2006 4:25 am    Post subject: Re: HOWTO: #define macro m(x,y,...) funcxyz(x,y,...) ??? Reply with quote

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





PostPosted: Tue Dec 26, 2006 5:36 am    Post subject: Re: HOWTO: #define macro m(x,y,...) funcxyz(x,y,...) ??? Reply with quote

"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





PostPosted: Tue Dec 26, 2006 6:27 am    Post subject: Re: HOWTO: #define macro m(x,y,...) funcxyz(x,y,...) ??? Reply with quote

"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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language C++) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.