From 2100b4ce152e9c70b3ce8760112d5a24ead4e52d Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Fri, 3 Apr 2020 21:34:45 -0400 Subject: Allow qpdf to be built on systems without wchar_t (fixes #406) --- libtests/main_from_wmain.cc | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 libtests/main_from_wmain.cc (limited to 'libtests/main_from_wmain.cc') diff --git a/libtests/main_from_wmain.cc b/libtests/main_from_wmain.cc new file mode 100644 index 00000000..c3e2a716 --- /dev/null +++ b/libtests/main_from_wmain.cc @@ -0,0 +1,34 @@ +#include +#include + +#ifndef QPDF_NO_WCHAR_T +void wmain_test() +{ + auto realmain = [](int argc, char* argv[]) { + for (int i = 0; i < argc; ++i) { + std::cout << argv[i] << std::endl; + } return 0; + }; + wchar_t* argv[3]; + argv[0] = const_cast(L"ascii"); + argv[1] = const_cast(L"10 \xf7 2 = 5"); + argv[2] = const_cast(L"qwww\xf7\x03c0"); + QUtil::call_main_from_wmain(3, argv, realmain); +} +#endif // QPDF_NO_WCHAR_T + +int main(int argc, char* argv[]) +{ +#ifndef QPDF_NO_WCHAR_T + try + { + wmain_test(); + } + catch (std::exception& e) + { + std::cout << "unexpected exception: " << e.what() << std::endl; + } +#endif // QPDF_NO_WCHAR_T + + return 0; +} -- cgit v1.2.3-54-g00ecf