From: "Dave Korn" <dave.korn@artimi.com>
To: "'count spatula'" <cygwin-talk@cygwin.com>
Subject: RE: how come #include "*.cpp" works?
Date: Wed, 24 May 2006 17:51:00 -0000 [thread overview]
Message-ID: <052a01c67f5a$a23dc860$a501a8c0@CAM.ARTIMI.COM> (raw)
In-Reply-To: <Pine.GSO.4.63.0605241321440.19906@access1.cims.nyu.edu>
On 24 May 2006 18:28, Igor Peshansky wrote:
> On Wed, 24 May 2006, Dave Korn wrote:
>> Perhaps it would be better to factor out the prototype generation into
>> a separate macro that could be invoked by both instances of "#define
>> CREATABLE_CLASS" ?
>
> What's wrong with the following?
>
> #define _CREATABLE_CLASS_DECL(name) \
> class name : virtual public OBJECT
> #define _CREATABLE_CLASS_PROTO(name) \
> extern class OBJECT* create_##name( int argc, const char* argv[] );
>
> #ifndef CC_NO_CLASS_DECL
> #define CREATABLE_CLASS(name) \
> _CREATABLE_CLASS_PROTO(name) \
> _CREATABLE_CLASS_DECL(name)
> #else
> #define CREATABLE_CLASS(name) \
> _CREATABLE_CLASS_PROTO(name)
> #endif
>
> and then, in main.cpp:
>
> #define CC_NO_CLASS_DECL
> #include "objects.def"
Well, there's nothing wrong with it. In fact it's exactly what I suggested
doing; you have factored out the prototype generation into a separate macro
called _CREATABLE_CLASS_PROTO. Sure, you've then gone on to refactor the
separate #definitions of CREATABLE_CLASS into one header that can be included
at each place; with a little more work it would be possible to factor the
table-building definition
#define CREATABLE_CLASS(name) { #name, create_##name },
in as well and then everything would be really nice and well-engineered.
cheers,
DaveK
--
Can't think of a witty .sigline today....
next prev parent reply other threads:[~2006-05-24 17:51 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 [this message]
2006-05-24 18:36 ` mwoehlke
2006-05-24 18:17 ` mwoehlke
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='052a01c67f5a$a23dc860$a501a8c0@CAM.ARTIMI.COM' \
--to=dave.korn@artimi.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).