I’m very new to c++20 modules and i’m trying this:
VariantFunctions.ixx
export module VariantFunctions;
struct tagVARIANT; // Forward declaration of VARIANT type
typedef struct tagVARIANT VARIANT;
export bool IsNonZeroI4x(const VARIANT & v) noexcept;
I’m trying to call this function from Win32 code which uses MFC like this:
VARIANT v;
VariantInit(&v);
IsNonZeroI4x(v);
The compiler (Visual Studio 2022, 17.11.3) tells me:
error C2664: ‘bool IsNonZeroI4x(const VARIANT &) noexcept’: cannot convert argument 1 from ‘VARIANT’ to ‘const VARIANT &’
I can write a similar function that takes a simple type, like a long
in the place of a VARIANT
, but I need to understand why the code above doesn’t work.
I’ve tried to use #include <oleauto>
in the .ixx
file, but there’s so many module-incompatible things in that header that it’s not possible, hence why I pondered a forward declaration.
stevew911 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1