qsharp-runtime
qsharp-runtime copied to clipboard
Make the Native Simulator API More Reusable and Reuse it in Runtime
The Native Simulator has the Dump call with the following declaration:
MICROSOFT_QUANTUM_DECL void Dump(_In_ unsigned sid, _In_ bool (*callback)(size_t, double, double));
Its second parameter's type is defined in-place, which prevents its reuse in the calling code in Runtime. The calling code has to re-define that type:
typedef bool (*TGetStateCallback)(size_t /*basis vector*/, double /* amplitude Re*/, double /* amplitude Im*/);
Also the Native Simulator is compiled into the dynamic library that exposes its API in the header capi.hpp, but the Runtime does not include that header. That is why the calling code in the Runtime re-declares all the Native Simulator's API function signatures, e.g. the Dump()
call signature is re-declared like this:
typedef bool (*TDump)(unsigned, TGetStateCallback);
(pay attention to the return type bool
as opposed to the actual return type void
in the first-most listing above).
To avoid re-declaration, start including the capi.hpp
in the Runtime.
See also #631.