{"action":"created","issue":{"url":"https://api.github.com/repos/ThePhD/sol2/issues/239","repository_url":"https://api.github.com/repos/ThePhD/sol2","labels_url":"https://api.github.com/repos/ThePhD/sol2/issues/239/labels{/name}","comments_url":"https://api.github.com/repos/ThePhD/sol2/issues/239/comments","events_url":"https://api.github.com/repos/ThePhD/sol2/issues/239/events","html_url":"https://github.com/ThePhD/sol2/issues/239","id":180837188,"number":239,"title":"sol2 tests fail when Lua is compiled as C++","user":{"login":"RaptorFactor","id":1245816,"avatar_url":"https://avatars.githubusercontent.com/u/1245816?v=3","gravatar_id":"","url":"https://api.github.com/users/RaptorFactor","html_url":"https://github.com/RaptorFactor","followers_url":"https://api.github.com/users/RaptorFactor/followers","following_url":"https://api.github.com/users/RaptorFactor/following{/other_user}","gists_url":"https://api.github.com/users/RaptorFactor/gists{/gist_id}","starred_url":"https://api.github.com/users/RaptorFactor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RaptorFactor/subscriptions","organizations_url":"https://api.github.com/users/RaptorFactor/orgs","repos_url":"https://api.github.com/users/RaptorFactor/repos","events_url":"https://api.github.com/users/RaptorFactor/events{/privacy}","received_events_url":"https://api.github.com/users/RaptorFactor/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":11,"created_at":"2016-10-04T08:50:07Z","updated_at":"2016-10-05T03:39:56Z","closed_at":null,"body":"Problem: Sol2 tests fail when Lua is compiled as C++ (not sure what else breaks, I hadn't got that far yet).\r\n\r\nsol2 version: v2.14.9\r\nLua version: v5.3.3\r\nPlatform: Windows\r\nCompiler: MSVC v19.00.24215.1 x64 (GCC v6.2.0 on mingw-w64 also suspected, although I haven't had time to confirm that yet)\r\n\r\nThis is what I hacked together to build Lua for this test (/TP and /EHsc are the most important things I think... I use a DLL here but iirc it should repro with a static lib also):\r\n`setlocal`\r\n`rd bin & md bin & cd bin`\r\n`set LUA_SOURCES=..\\src\\lapi.c ..\\src\\lauxlib.c ..\\src\\lbaselib.c ..\\src\\lbitlib.c ..\\src\\lcode.c ..\\src\\lcorolib.c ..\\src\\lctype.c ..\\src\\ldblib.c ..\\src\\ldebug.c ..\\src\\ldo.c ..\\src\\ldump.c ..\\src\\lfunc.c ..\\src\\lgc.c ..\\src\\linit.c ..\\src\\liolib.c ..\\src\\llex.c ..\\src\\lmathlib.c ..\\src\\lmem.c ..\\src\\loadlib.c ..\\src\\lobject.c ..\\src\\lopcodes.c ..\\src\\loslib.c ..\\src\\lparser.c ..\\src\\lstate.c ..\\src\\lstring.c ..\\src\\lstrlib.c ..\\src\\ltable.c ..\\src\\ltablib.c ..\\src\\ltm.c ..\\src\\lundump.c ..\\src\\lutf8lib.c ..\\src\\lvm.c ..\\src\\lzio.c`\r\n`cl /EHsc /MDd /TP /LD /DLUA_BUILD_AS_DLL /Felua53.dll %LUA_SOURCES%`\r\n`cl /EHsc /MDd /TP /DLUA_BUILD_AS_DLL ..\\src\\lua.c /link lua53.lib`\r\n`cl /EHsc /MDd /TP ..\\src\\luac.c %LUA_SOURCES%`\r\n\r\n\r\nNote: In order to compile Lua as C++ you need to make a couple of tweaks to some code that is legal in C but illegal in C++, but it's only a couple of lines and it's as simple as adding a cast. You'll also need to modify lua.hpp to remove the extern \"C\" wrapper. More on that below...\r\n\r\nHere's the one for Sol2:\r\n`del tests.exe`\r\n`del *.obj`\r\n`cl /MDd /EHsc /bigobj /Isingle/sol /Icatch/include /IC:\\My\\Code\\lua-5.3.3\\src tests.cpp test_containers.cpp test_coroutines.cpp test_customizations.cpp test_functions.cpp test_inheritance.cpp test_operators.cpp test_overflow.cpp test_simple_usertypes.cpp test_strings.cpp test_tables.cpp test_usertypes.cpp /link C:\\My\\Code\\lua-5.3.3\\bin\\lua53.lib `\r\n\r\nExpected test summary output:\r\n\r\n> All tests passed (940 assertions in 138 test cases)\r\n\r\nActual test summary output:\r\n> test cases: 138 | 137 passed | 1 failed\r\n> assertions: 930 | 929 passed | 1 failed\r\n\r\nFailing test output:\r\n\r\n> -------------------------------------------------------------------------------\r\n> functions/function_result-protected_function_result\r\n> -------------------------------------------------------------------------------\r\n> test_functions.cpp(269)\r\n> ...............................................................................\r\n> \r\n> test_functions.cpp(269): FAILED:\r\n>   {Unknown expression after the reported line}\r\n> due to unexpected exception with message:\r\n>   lua: error: stack index 1, expected string, received function\r\n\r\nBack to compiling Lua as C++... I was under the impression that this was supposed to be a supported and tested scenario, because the Lua website states \"Lua also compiles cleanly as C++.\", but I guess nobody is really using it in practice? I'm curious why this is... I'm just on the initial bring-up stages of my new project which uses Lua, but I thought that in order to be able to throw exceptions through the Lua DLL that I'd need to compile it as C++, which in turn led me to assume there were a lot of other people who must be doing the same thing... Is this incorrect? How is everyone else dealing with exceptions? (e.g. A.exe -> Lua53.dll -> B.dll - Assuming the methods exposed to Lua from B.dll can throw exceptions)\r\n\r\nAlso, what's up with lua.hpp? It says that extern \"C\" is not automatically provided (presumably because people like me want to compile Lua as C++), and then they proceed to do exactly the thing they just said they wouldn't do... I feel like the fact that I'm hitting all these problems means I must be \"holding it wrong\", so I'd be very curious to hear if you think I'm on the wrong path for whatever reason.\r\n\r\nP.S. Sorry, I know you're not responsible for Lua itself, but I haven't been able to find a good answer anywhere else, and now that I already have your attention I may as well ask. ;)"},"comment":{"url":"https://api.github.com/repos/ThePhD/sol2/issues/comments/251574317","html_url":"https://github.com/ThePhD/sol2/issues/239#issuecomment-251574317","issue_url":"https://api.github.com/repos/ThePhD/sol2/issues/239","id":251574317,"user":{"login":"ThePhD","id":2886436,"avatar_url":"https://avatars.githubusercontent.com/u/2886436?v=3","gravatar_id":"","url":"https://api.github.com/users/ThePhD","html_url":"https://github.com/ThePhD","followers_url":"https://api.github.com/users/ThePhD/followers","following_url":"https://api.github.com/users/ThePhD/following{/other_user}","gists_url":"https://api.github.com/users/ThePhD/gists{/gist_id}","starred_url":"https://api.github.com/users/ThePhD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ThePhD/subscriptions","organizations_url":"https://api.github.com/users/ThePhD/orgs","repos_url":"https://api.github.com/users/ThePhD/repos","events_url":"https://api.github.com/users/ThePhD/events{/privacy}","received_events_url":"https://api.github.com/users/ThePhD/received_events","type":"User","site_admin":false},"created_at":"2016-10-05T03:39:55Z","updated_at":"2016-10-05T03:39:55Z","body":"So #238 might have been related to this and not entirely about exceptions working or not working, and it's fixed. Give it a shot: https://github.com/ThePhD/sol2/releases/tag/v2.14.9"}}
{"actor":{"display_login":"ThePhD"}}