[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: build the same source twice with different macros

From: Nick Bowler
Subject: Re: build the same source twice with different macros
Date: Mon, 15 Nov 2010 11:17:19 -0500
User-agent: Mutt/1.5.20 (2009-06-14)

On 2010-11-15 09:11 -0700, Nicolas Bock wrote:
> Hello list,
> I have some functions written in C that take a floating point argument, e.g.
> void foos (float x);
> void food (double x);
> The function bodies are basically identical except of course for the
> different floating point types. In order to avoid having to write
> redundant code, I see 2 options:
> (1) I can use C++ and rewrite the function header as a template.
> (2) I can define a macro for the preprocessor that is either defined
> as "float" or "double" and then compile the function source twice, the
> first time with $CC -DFLOAT=float and the second time with $CC
> -DFLOAT=double.
> Is option (2) possible within automake without excessive hackery? Is
> it advisable? Is there a third option that I might want to consider?

Option (2) can be done easily with libtool convenience libraries: simply
use one convenience library for each set of CPPFLAGS, then link both
into your final program or library.

Nick Bowler, Elliptic Technologies (

reply via email to

[Prev in Thread] Current Thread [Next in Thread]