You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use meshoptimizer in a Visual Studio project that overrides the default calling convention with __vectorcall (/Gv), and seeing compilation failures in src/meshoptimizer.h:
This appears to be because the MSVC C++ libs explicitly mark operator new and operator delete as __cdecl, rather than implicitly picking up the calling convention from the compiler settings. Since your allocator/deallocate free-function pointers don't specify a calling convention, they get __vectorcall implicitly in this scenario, and thus become incompatible with operator new.
Explicitly changing the calling convention back to __cdecl for the translation unit allows it to compile OK, but then causes linker errors because the other translation units that include meshoptimizer.h are still set to __vectorcall. The only path I can see to using the library in its current form is to change the whole project back to __cdecl, but that comes at a runtime performance cost I'd like to avoid.
(I could also get around it by wrapping the library it in a separately-compiled library and forwarding all the calls through shims with explicit calling conventions, but that's clearly a big headache.)
Would you be amenable to adding a user-configurable #define for explicitly specifying the calling convention of alloc+dealloc function pointers? I'd be happy to prepare a PR for this myself.
The text was updated successfully, but these errors were encountered:
Hello,
I'm trying to use
meshoptimizer
in a Visual Studio project that overrides the default calling convention with__vectorcall
(/Gv
), and seeing compilation failures insrc/meshoptimizer.h
:This appears to be because the MSVC C++ libs explicitly mark
operator new
andoperator delete
as__cdecl
, rather than implicitly picking up the calling convention from the compiler settings. Since your allocator/deallocate free-function pointers don't specify a calling convention, they get__vectorcall
implicitly in this scenario, and thus become incompatible withoperator new
.Explicitly changing the calling convention back to
__cdecl
for the translation unit allows it to compile OK, but then causes linker errors because the other translation units that includemeshoptimizer.h
are still set to__vectorcall
. The only path I can see to using the library in its current form is to change the whole project back to__cdecl
, but that comes at a runtime performance cost I'd like to avoid.(I could also get around it by wrapping the library it in a separately-compiled library and forwarding all the calls through shims with explicit calling conventions, but that's clearly a big headache.)
Would you be amenable to adding a user-configurable
#define
for explicitly specifying the calling convention of alloc+dealloc function pointers? I'd be happy to prepare a PR for this myself.The text was updated successfully, but these errors were encountered: