Skip to content

Commit

Permalink
Explicitly specify __cdecl on main/wmain for MSVC (#2487)
Browse files Browse the repository at this point in the history
Fixes #2486

Co-authored-by: Martin Hořeňovský <martin.horenovsky@gmail.com>
  • Loading branch information
davidmatson and horenmar authored Aug 6, 2022
1 parent 20d413b commit 14bc25b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions include/internal/catch_default_main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,20 @@

#ifndef __OBJC__

#ifndef CATCH_INTERNAL_CDECL
#ifdef _MSC_VER
#define CATCH_INTERNAL_CDECL __cdecl
#else
#define CATCH_INTERNAL_CDECL
#endif
#endif

#if defined(CATCH_CONFIG_WCHAR) && defined(CATCH_PLATFORM_WINDOWS) && defined(_UNICODE) && !defined(DO_NOT_USE_WMAIN)
// Standard C/C++ Win32 Unicode wmain entry point
extern "C" int wmain (int argc, wchar_t * argv[], wchar_t * []) {
extern "C" int CATCH_INTERNAL_CDECL wmain (int argc, wchar_t * argv[], wchar_t * []) {
#else
// Standard C/C++ main entry point
int main (int argc, char * argv[]) {
int CATCH_INTERNAL_CDECL main (int argc, char * argv[]) {
#endif

return Catch::Session().run( argc, argv );
Expand Down

0 comments on commit 14bc25b

Please sign in to comment.