From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16828 invoked by alias); 24 May 2006 17:14:44 -0000 Received: (qmail 16777 invoked by uid 22791); 24 May 2006 17:14:44 -0000 X-Spam-Check-By: sourceware.org Received: from mail.artimi.com (HELO mail.artimi.com) (217.40.213.68) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 24 May 2006 17:14:42 +0000 Received: from mail.artimi.com ([192.168.1.3]) by mail.artimi.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 24 May 2006 18:14:39 +0100 Received: from rainbow ([192.168.1.165]) by mail.artimi.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 24 May 2006 18:14:38 +0100 From: "Dave Korn" To: "'This post is shamefully lacking in hippos.'" Subject: RE: how come #include "*.cpp" works? Date: Wed, 24 May 2006 17:14:00 -0000 Message-ID: <052701c67f55$89e7b7d0$a501a8c0@CAM.ARTIMI.COM> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 11 In-Reply-To: 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/msg00315.txt.bz2 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__ ); \ > Thus, except for Makefile, it achieves the objective of having a list > which is entirely generated and does not need to be maintained by hand. > === 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. You run the danger of getting inconsistent code. In this case, unless T_OBJ is the exact same type as OBJECT, you've already made (technically speaking) undefined behaviour, haven't you? Umm, perhaps I mean "Would someone remined me whether C++ mangled names include the return type, or just the args signature?" 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" ? cheers, DaveK -- Can't think of a witty .sigline today....