12 Mar 2013, 10:21
Generic-user-small

Arnd R.Strube (57 posts)

Hello James,

In this header file, you will find the following method definition:

static MockFunctionCall& instance() { 
    static MockIgnoredCall call; 
    return call;
};

While this does not seem to be a problem with “decent” compilers, TI’s cl2000 (a somewhat dated version, too), which I am forced to use at work, cannot handle this and produces several copies of “call”, resulting in linker errors later on. Now I wouldn’t normally suggest you change the code because of just one kinky, ancient compiler out there, but…

I noticed that this is actually the only instance of “instance()” that is defined right inside the header file. So maybe you would consider moving the definition to MockFunctionCall.cpp like the others? At least, this would also be more consistent (I had a look at CppUTest 3.3, where it is still defined in the header file).

Meanwhile, I am working with a platform-specific copy of the header, which lives in ..\include\Platforms\c2000, but it’s always a bit of a tricky business to correctly include a header that also lives elsewhere in the normal include path…

As an aside - this looks like a somewhat unusual rendering of the Singleton Pattern (or is it?) - would you care to explain why you did things the way you did?

Thanks, Arnd

  You must be logged in to comment