Skip to content

Commit

Permalink
Specify __cdecl on main/wmain, as required by x86 (fixes catchorg#2486).
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmatson committed Jul 26, 2022
1 parent 20d413b commit e390b9b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions docs/own-main.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ If you just need to have code that executes before and/ or after Catch this is t
#define CATCH_CONFIG_RUNNER
#include "catch.hpp"

int main( int argc, char* argv[] ) {
extern "C" int __cdecl main( int argc, char* argv[] ) {
// global setup...

int result = Catch::Session().run( argc, argv );
Expand All @@ -42,7 +42,7 @@ If you still want Catch to process the command line, but you want to programmati
#define CATCH_CONFIG_RUNNER
#include "catch.hpp"
int main( int argc, char* argv[] )
int __cdecl main( int argc, char* argv[] )
{
Catch::Session session; // There must be exactly one instance
Expand Down Expand Up @@ -80,7 +80,7 @@ so extending Catch's own command line options is now easy.
#define CATCH_CONFIG_RUNNER
#include "catch.hpp"

int main( int argc, char* argv[] )
int __cdecl main( int argc, char* argv[] )
{
Catch::Session session; // There must be exactly one instance

Expand Down
4 changes: 2 additions & 2 deletions include/internal/catch_default_main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@

#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 __cdecl wmain (int argc, wchar_t * argv[], wchar_t * []) {
#else
// Standard C/C++ main entry point
int main (int argc, char * argv[]) {
int __cdecl main (int argc, char * argv[]) {
#endif

return Catch::Session().run( argc, argv );
Expand Down
2 changes: 1 addition & 1 deletion misc/coverage-helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ int exec_cmd(std::string const& cmd, int log_num, std::string const& path) {
// [2]: "--sep--"
// [3]+: the actual command

int main(int argc, char** argv) {
int __cdecl main(int argc, char** argv) {
std::vector<std::string> args(argv, argv + argc);
auto sep = std::find(begin(args), end(args), separator);
assert(sep - begin(args) == 2 && "Structure differs from expected!");
Expand Down
2 changes: 1 addition & 1 deletion single_include/catch2/catch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17531,7 +17531,7 @@ namespace Catch {
extern "C" int wmain (int argc, wchar_t * argv[], wchar_t * []) {
#else
// Standard C/C++ main entry point
int main (int argc, char * argv[]) {
int __cdecl main (int argc, char * argv[]) {
#endif

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

0 comments on commit e390b9b

Please sign in to comment.