From owner-freebsd-chat@FreeBSD.ORG Tue Mar 29 13:44:42 2005 Return-Path: Delivered-To: freebsd-chat@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 844A316A4CE for ; Tue, 29 Mar 2005 13:44:42 +0000 (GMT) Received: from xenial.mcc.ac.uk (xenial.mcc.ac.uk [130.88.203.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id C2D2043D1F for ; Tue, 29 Mar 2005 13:44:41 +0000 (GMT) (envelope-from jcm@FreeBSD-uk.eu.org) Received: from dogma.freebsd-uk.eu.org ([130.88.200.97]) by xenial.mcc.ac.uk with esmtp (Exim 4.43 (FreeBSD)) id 1DGH1M-0004PC-Oo for freebsd-chat@freebsd.org; Tue, 29 Mar 2005 14:44:40 +0100 Received: from dogma.freebsd-uk.eu.org (localhost [127.0.0.1]) j2TDia9B089773 for ; Tue, 29 Mar 2005 14:44:40 +0100 (BST) (envelope-from jcm@dogma.freebsd-uk.eu.org) Received: (from jcm@localhost) by dogma.freebsd-uk.eu.org (8.13.1/8.12.6/Submit) id j2TDiZit089772 for freebsd-chat@freebsd.org; Tue, 29 Mar 2005 14:44:36 +0100 (BST) Date: Tue, 29 Mar 2005 14:44:35 +0100 From: Jonathon McKitrick To: freebsd-chat@freebsd.org Message-ID: <20050329134435.GA89346@dogma.freebsd-uk.eu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4i Subject: 'Base class' shared libraries in C? X-BeenThere: freebsd-chat@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Non technical items related to the community List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Mar 2005 13:44:42 -0000 Hi all, I am trying to implement some C++ functionality in C. Suppose I have several libraries that share behavior and properties, such as version, working directory, and so on. I want other libraries to extend this behavior without having to duplicate any code. For instance: typedef struct base { char version[32]; char path[32]; } base_t; typedef struct foo { base_t *base; int data; } foo_t; typedef struct bar { base_t *base; int data; } bar_t; lib-base.so: base_get_version(base_t *, char *); base_get_path(base_t *, char *); lib-derived-foo.so: foo_one_method(foo_t *, int data); foo_two_method(foo_t *, int data); lib-derived-bar.so: bar_one_method(bar_t *, int data); bar_two_method(bar_t *, int data); I want the derived modules to link with the base library, so that my application can link with only the derived modules and still be able to call the base functions without having to link to that library or call 'wrapper' functions in the derived modules. Is there a way to do this? jm --