From: mwoehlke <mwoehlke@tibco.com>
To: cygwin-talk@cygwin.com
Subject: Re: how come #include "*.cpp" works?
Date: Wed, 24 May 2006 18:17:00 -0000 [thread overview]
Message-ID: <e527up$7lo$1@sea.gmane.org> (raw)
In-Reply-To: <052701c67f55$89e7b7d0$a501a8c0@CAM.ARTIMI.COM>
Dave Korn wrote:
> On 24 May 2006 17:00, mwoehlke wrote:
>> 3: A create_<name> function must be written. If all objects were
>> constructed the same, this could have been lumped into the declaration
>> CREATABLE_CLASS macro, however not all constructors take the same
>> arguments, which is why 'create_<name>' takes an argc/argv pair. IOW
>> this requirement cannot be eliminated.
>
> Are you sure this can't be worked around using varargs macros?
>
> #define CREATABLE_CLASS(name, ...) \
> extern class OBJECT* create_##name( __VA_ARGS__ ); \
Hehe, good try :-), but "no"... First, how would you know how to invoke
the create function like that? Second, 'argc' and 'argv' are actually
being passed direct from the command line; the idea is that the
individual create function deals with the args, so that the upper level
doesn't need to know what the args should look like for a particular
object type.
>> === For declaring an object
>> #define CREATABLE_CLASS(name) \
>> extern class OBJECT* create_##name( int argc, const char* argv[] ); \
>> class name : virtual public OBJECT
>
>> === So main.cpp doesn't need the headers for every class
>> #undef CREATABLE_CLASS
>> #define CREATABLE_CLASS(name) \
>> extern class T_OBJ* create_##name( int argc, const char* argv[] );
>> #include "objects.def"
>
> Bad idea, I think. You now have two separate bits of code that are
> generating the prototypes for this set of functions. [snip]
Oh, oops... it's actually 'T_OBJ' in my code; I was trying to replace it
with 'OBJECT'. So, 'OBJECT' == 'T_OBJ'.
--
Matthew
Doom doom dooM doo-DooM dOOm DOom doOM... DOOM! -- Gir
next prev parent reply other threads:[~2006-05-24 18:17 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <44638BED.5020009@telenet.be>
[not found] ` <4463A0D4.1060006@cygwin.com>
2006-05-17 15:52 ` mwoehlke
2006-05-17 16:00 ` Dave Korn
2006-05-17 16:28 ` Igor Peshansky
2006-05-17 16:57 ` Dave Korn
2006-05-18 14:46 ` mwoehlke
2006-05-18 16:59 ` Jason Alonso
2006-05-18 17:24 ` Dave Korn
2006-05-18 18:28 ` mwoehlke
2006-05-18 18:31 ` Dave Korn
2006-05-18 19:10 ` mwoehlke
2006-05-24 16:03 ` mwoehlke
2006-05-24 17:14 ` Dave Korn
2006-05-24 17:28 ` Igor Peshansky
2006-05-24 17:51 ` Dave Korn
2006-05-24 18:36 ` mwoehlke
2006-05-24 18:17 ` mwoehlke [this message]
2006-05-17 17:01 ` Dave Korn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='e527up$7lo$1@sea.gmane.org' \
--to=mwoehlke@tibco.com \
--cc=cygwin-talk@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).