How to get go build cgo to compile for later versions of windows compiler

I have a custom go project that I’m compiling as c-shared in order to use across OS platforms. The C header has a small #ifdef section that checks for _MSC_VER (the microsoft compiler). This section is causing compilation failures with vs studio 2022. Errors are like “C4430: missing type specifier - int assumed” and “C2146: syntax error: missing ‘;’ before identifier ‘GoComplex64’”. However when I manually change the code section (I have the change below) it compiles. So based on the code below is there a flag or something I can send go build to build to the desired types?

// the build command
go build -trimpath -buildmode=c-shared -o keyring.dll ./src/go

// the resulting C header section, which msvc is having trouble with

#ifdef _MSC_VER
#include <complex.h>
typedef _Fcomplex GoComplex64;
typedef _Dcomplex GoComplex128;
#else

// this is the manual change I made, which msvc accepts

#ifdef _MSC_VER
  #include <complex>
     typedef std::complex<float> GoComplex64;
     typedef std::complex<double> GoComplex128;
#else

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.