Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 25 Feb 2005 08:28:30 +0200
From:      Giorgos Keramidas <keramida@ceid.upatras.gr>
To:        Kathy Quinlan <kat-free@kaqelectronics.dyndns.org>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: gcc question
Message-ID:  <20050225062830.GD886@gothmog.gr>
In-Reply-To: <421E9CD7.5060503@kaqelectronics.dyndns.org>
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>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2005-02-25 11:34, Kathy Quinlan <kat-free@kaqelectronics.dyndns.org> 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050225062830.GD886>