On 11/17/2010 03:10 AM, Ian Lance Taylor wrote:
Joern Rennecke<amyl...@spamcop.net> writes:
I don't see how going to a struct cumulative_args gets us closer
to a viable solution for a multi-target executable, even if you
threw in C++. Having the target describe a type, and shoe-horning
this through a target hook interface that is decribed in supposedly
target-independent terms will require a cast at some point. [...]
Converting an empty base class to a derived class is not really
safer than converting a void * to a struct pointer.
True, but you can hide that cast in a base class. For example you can
use a hierarchy
Target // abstract base
TargetImplBase<TargetI386> // provides strong typing
TargetI386 // actual implementation
The Target class would indeed take a void *, but the middle class would
let TargetI386 think in terms of TargetI386::CumulativeArgs with
something like
void f(void *x) {
// T needs to provide void T::f(T::CumulativeArgs *)
f(static_cast<T::CumulativeArgs *> (x));
}
The most similar thing in C (though not suitable for multitarget) is a
struct, which is why I suggest using that now rather than void * (which
would be an implementation detail).
Paolo