Q:

How to optimize an external reference to an interface in C++?

Using VC8, I create two modules similar to the following:
Header
class IFoo
{
    virtual void Bar() = 0;
};

Module A
extern IFoo& Foo;

void DoStuff()
{
    Foo.Bar();
}

Module B
IFoo& Foo = ConcreteFoo();

VC8 handles this by essentially treating 'Foo' as a pointer to an IFoo.  Wherever it sees Foo.Bar() (even in module B), it derefences the pointer to get the object's vtable, looks up the address of Bar() and calls it.  This is a little irritating since Foo does in fact refer to a concrete object and always will.  It would be nice if you could do something like the following:
Module A
extern __concrete IFoo& Foo;

This would tell the compiler that you promise to provide a concrete object to back this reference.  It could then generate a special external reference to Foo.Bar() and directly call the method without the double dereferencing.
As far as I can tell, there's no way to do this with Visual C++, which leads to two questions:

Is there a way to get the VC compiler to generate the direct method call?
Are there any other C++ compilers that can do it?

A:

Don't worry about one tiny little vtable lookup, unless profiling indicates that it's a bottleneck. (Hint: it probably won't be.)
How should the compiler know what the concrete return type of ConcreteFoo() is going to be? If Foo::Bar() is virtual, the compiler cannot create a static call to Foo.Bar() because Foo's type is unknown at compile time.
If you know the actual type of Foo, say Biz, you can do away with the reference:
Module A
extern Biz Foo;

Module B
Biz Foo = ConcreteFoo();

(assuming that Biz has a copy constructor.)

