Data Acquisition (DAQ) and Control from Microstar Laboratories

Knowledge Base: Installation

Q10118 Compiler complains about 'PureCallMsl' in custom command build

Tags: Help, Custom command, upgrades, C++ compiler

Applies to: DAPtools Professional software version 6.10, a-Series DAP boards, Develper's Toolkit for DAPL, DTD version 5.20, DAPL 2000

I upgraded my DAPtools software to the 6.10 version that I purchased with a new board, including the Developer's Toolkit for DAPL 5.20 that came with it. Now the source code of my custom command module does not compile. The linker complains about a function PureCallMsl that does not exist. How do I fix this?

While seldom needed, there are special cases where classes with pure virtual functions are helpful in custom command code. Support for this feature was added with the Developer's Toolkt for DAPL (DTD) 5.20 release. Though no valid program would ever call a virtual function without defining it first, the C++ language does not protect against that kind of error. To deal with this difficulty, the Microsoft compiler points each uninitialized pure virtual function to a placeholder function __purecall for deciding whether to raise an exception or process the error some other way. There is nothing wrong with this idea, except that the implementation of the __purecall function was placed in the Windows system libraries where custom command code could not reach it.

We knew this, and substituted an equivalent function that the DAPL system could process. This works fine when compiling custom commands to run on the xDAP family and DAPL 3000 system. But on older systems using versions of the DAPL 2000 system that don't know about the new replacement function, references to the new function can fail to resolve correctly. This problem can cause compile errors even if you don't define any C++ classes.

Until a DAPtools 6.11 release is available to provide a cleaner and more permanent fix, if you need to use the DAPtools Software version 6.10 (typically because of its 64-bit support) and you need to compile commands to run on PCI- bus DAP boards under DAPL 2000, you have two ways to do this.

  1. Use the previous Developer's Toolkit for DAPL version 5.10, which does not have this problem — but you must forgo using any pure virtual functions in your C++ classes. (You can implement similar functionality with function pointers if necessary.)

  2. You can define the function the linker wants to see. Patch the following line into the declarations near the top of your source code file.

       extern "C" int __stdcall PureCallMsl(void) { return 8; }

    When never executed, this function never returns the meaningless value, and everybody is happy.