gcc question

Giorgos Keramidas keramida at ceid.upatras.gr
Fri Feb 25 06:28:56 GMT 2005


On 2005-02-25 11:34, Kathy Quinlan <kat-free at 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



More information about the freebsd-hackers mailing list