From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29569 invoked by alias); 24 May 2006 18:17:22 -0000 Received: (qmail 29554 invoked by uid 22791); 24 May 2006 18:17:20 -0000 X-Spam-Check-By: sourceware.org Received: from main.gmane.org (HELO ciao.gmane.org) (80.91.229.2) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 24 May 2006 18:17:16 +0000 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1Fixup-0006L7-VV for cygwin-talk@cygwin.com; Wed, 24 May 2006 20:17:03 +0200 Received: from 65.207.213.226 ([65.207.213.226]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 24 May 2006 20:17:03 +0200 Received: from mwoehlke by 65.207.213.226 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 24 May 2006 20:17:03 +0200 To: cygwin-talk@cygwin.com From: mwoehlke Subject: Re: how come #include "*.cpp" works? Date: Wed, 24 May 2006 18:17:00 -0000 Message-ID: References: <052701c67f55$89e7b7d0$a501a8c0@CAM.ARTIMI.COM> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit User-Agent: Thunderbird 1.5.0.2 (X11/20060420) In-Reply-To: <052701c67f55$89e7b7d0$a501a8c0@CAM.ARTIMI.COM> X-IsSubscribed: yes Mailing-List: contact cygwin-talk-help@cygwin.com; run by ezmlm Precedence: bulk List-Subscribe: List-Post: List-Help: , Sender: cygwin-talk-owner@cygwin.com Reply-To: The Cygwin-Talk Maiming List X-SW-Source: 2006-q2/txt/msg00320.txt.bz2 Dave Korn wrote: > On 24 May 2006 17:00, mwoehlke wrote: >> 3: A create_ 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_' 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