From owner-freebsd-hackers@FreeBSD.ORG Fri Feb 25 06:28:56 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 771C316A4CE for ; Fri, 25 Feb 2005 06:28:56 +0000 (GMT) Received: from kane.otenet.gr (kane.otenet.gr [195.170.0.27]) by mx1.FreeBSD.org (Postfix) with ESMTP id EA38643D1F for ; Fri, 25 Feb 2005 06:28:54 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from gothmog.gr (patr530-b169.otenet.gr [212.205.244.177]) j1P6SdMG016165; Fri, 25 Feb 2005 08:28:40 +0200 Received: from gothmog.gr (gothmog [127.0.0.1]) by gothmog.gr (8.13.3/8.13.3) with ESMTP id j1P6SV3w001848; Fri, 25 Feb 2005 08:28:31 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Received: (from giorgos@localhost) by gothmog.gr (8.13.3/8.13.3/Submit) id j1P6SUMc001847; Fri, 25 Feb 2005 08:28:30 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Date: Fri, 25 Feb 2005 08:28:30 +0200 From: Giorgos Keramidas To: Kathy Quinlan Message-ID: <20050225062830.GD886@gothmog.gr> References: <421D584A.90203@kaqelectronics.dyndns.org> <200502241532.50010.doconnor@gsoft.com.au> <421D81E9.809@kaqelectronics.dyndns.org> <200502251230.59147.doconnor@gsoft.com.au> <421E9CD7.5060503@kaqelectronics.dyndns.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <421E9CD7.5060503@kaqelectronics.dyndns.org> X-Mailman-Approved-At: Fri, 25 Feb 2005 12:58:20 +0000 cc: freebsd-hackers@freebsd.org Subject: Re: gcc question X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Feb 2005 06:28:56 -0000 On 2005-02-25 11:34, Kathy Quinlan wrote: >Daniel O'Connor wrote: >>On Thu, 24 Feb 2005 17:57, Kathy Quinlan wrote: >>> ATM it is written in codevisionAVR which is where the function is >>> called, so I guess for now I will just break the AVR support;) >> >> Ahh.. >> So.. are you talking about getting the coding running _in FreeBSD_ or >> compiled on FreeBSD and running on an AVR? > > I am talking about getting the same code running under FreeBSD AND the > AVR with minimal changes. The easiest way is to hide the differences of the two platforms under a properly designed abstraction layer. IIRC, it was putchar() that was giving you trouble. Don't call it as putchar(), then. Write a wrapper function, which gets properly defined either for either system. The header that defines the wrapped functions' API can be common, i.e.: #ifndef __WRAPPER_H #define __WRAPPER_H #ifdef __cplusplus extern "C" { #endif int sendbyte(int val); #ifdef __cplusplus } #endif #endif /* __WRAPPER_H */ The implementation of the sendbyte() function may be in either a common file sprinkled with #ifdef's for othe various platforms, or in separate files that are conditionally added to the build depending on the current platform. I hope this helps, Giorgos