One day, everything will build proper.

One day.
This commit is contained in:
ThePhD 2018-02-17 11:00:27 -05:00
parent 258acff99b
commit b78d900d05
6 changed files with 12 additions and 20 deletions

View File

@ -256,6 +256,8 @@ if (DO_TESTS OR DO_EXAMPLES)
if (IS_X86)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32")
set(CMAKE_EXECUTABLE_LINKER_FLAGS "${CMAKE_EXECUTABLE_LINKER_FLAGS} -m32")
endif()
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)

View File

@ -286,7 +286,7 @@ usertype arguments - simple usertype
runtime functions
-----------------
You can add functions at runtime **to the whole class**. Set a name under the metatable name you bound using ``new_usertype``/``new_simple_usertype`` to an object. For example:
You can add functions at runtime **to the whole class** (not to individual objects). Set a name under the metatable name you bound using ``new_usertype``/``new_simple_usertype`` to an object. For example:
.. code-block:: cpp
:linenos:
@ -393,6 +393,9 @@ compilation speed
If you find that compilation times are too long and you're only binding member functions, consider perhaps using :doc:`simple usertypes<simple_usertype>`. This can reduce compile times (but may cost memory size and speed). See the simple usertypes documentation for more details.
.. note::
MSVC and clang/gcc may need additional compiler flags to handle compiling extensive use of usertypes. See: :ref:`the error documentation<compilation_errors_warnings>` for more details.
performance note
----------------
@ -401,14 +404,6 @@ performance note
Note that performance for member function calls goes down by a fixed overhead if you also bind variables as well as member functions. This is purely a limitation of the Lua implementation and there is, unfortunately, nothing that can be done about it. If you bind only functions and no variables, however, Sol will automatically optimize the Lua runtime and give you the maximum performance possible. *Please consider ease of use and maintenance of code before you make everything into functions.*
MSVC note
---------
.. note::
When using usertype templates extensively, MSVC may invoke `compiler error C1128 <https://msdn.microsoft.com/en-us/library/8578y171.aspx>`_ , which is solved by using the `/bigobj compilation flag <https://msdn.microsoft.com/en-us/library/ms173499.aspx>`_.
.. _destructible: http://en.cppreference.com/w/cpp/types/is_destructible
.. _default_constructible: http://en.cppreference.com/w/cpp/types/is_constructible
.. _runtime extensible: https://github.com/ThePhD/sol2/blob/develop/examples/usertype_advanced.cpp#L81

View File

@ -10,6 +10,8 @@ Running Scripts
Scripts can have syntax errors, can load from the file system wrong, or have runtime issues. Knowing which one can be troublesome. There are various small building blocks to load and run code, but to check errors you can use the overloaded :ref:`script/script_file functions on sol::state/sol::state_view<state-script-function>`, specifically the ``safe_script`` variants. These also take an error callback that is called only when something goes wrong, and Sol comes with some default error handlers in the form of ``sol::script_default_on_error`` and ``sol::script_pass_on_error``.
.. _compilation_errors_warnings:
Compiler Errors / Warnings
--------------------------
@ -18,6 +20,7 @@ A myriad of compiler errors can occur when something goes wrong. Here is some ba
* If there are a myriad of errors relating to ``std::index_sequence``, type traits, and other ``std::`` members, it is likely you have not turned on your C++14 switch for your compiler. Visual Studio 2015 turns these on by default, but g++ and clang++ do not have them as defaults and you should pass the flag ``--std=c++1y`` or ``--std=c++14``, or similar for your compiler.
* Sometimes, a generated usertype can be very long if you are binding a lot of member functions. You may end up with a myriad of warnings about debug symbols being cut off or about ``__LINE_VAR`` exceeding maximum length. You can silence these warnings safely for some compilers.
* Template depth errors may also be a problem on earlier versions of clang++ and g++. Use ``-ftemplate-depth`` compiler flag and specify really high number (something like 2048 or even double that amount) to let the compiler work freely. Also consider potentially using :doc:`simple usertypes<api/simple_usertype>` to save compilation speed.
* When using usertype templates extensively, MSVC may invoke `compiler error C1128 <https://msdn.microsoft.com/en-us/library/8578y171.aspx>`_ , which is solved by using the `/bigobj compilation flag <https://msdn.microsoft.com/en-us/library/ms173499.aspx>`_.
* If you have a move-only type, that type may need to be made ``readonly`` if it is bound as a member variable on a usertype or bound using ``state_view::set_function``. See :doc:`sol::readonly<api/readonly>` for more details.
* Assigning a ``std::string`` or a ``std::pair<T1, T2>`` using ``operator=`` after it's been constructed can result in compiler errors when working with ``sol::function`` and its results. See `this issue for fixes to this behavior`_.
* Sometimes, using ``__stdcall`` in a 32-bit (x86) environment on VC++ can cause problems binding functions because of a compiler bug. We have a prelimanry fix in, but if it doesn't work and there are still problems: put the function in a ``std::function`` to make the compiler errors and other problems go away. Also see `this __stdcall issue report`_ for more details.

View File

@ -81,9 +81,6 @@ function (MAKE_EXAMPLE example_source_file is_single)
target_compile_options(${example_name}
PRIVATE -Wno-noexcept-type)
endif()
if (IS_X86)
target_compile_options(${example_name} BEFORE PRIVATE -m32)
endif()
if (TESTS_EXAMPLES)
if ((NOT is_single) OR (is_single AND TESTS_SINGLE))

View File

@ -99,10 +99,6 @@ function(make_require_from_dll_example target_lib is_single)
target_link_libraries(${example_name} PRIVATE ${LUA_LIBRARIES})
endif()
target_include_directories(${example_name} PRIVATE ${LUA_INCLUDE_DIRS})
if (IS_X86)
target_compile_options(${example_name} BEFORE PRIVATE -m32)
endif()
if (TESTS_DYNAMIC_LOADING_EXAMPLES)
if ((NOT is_single) OR (is_single AND DYNAMIC_LOADING_EXAMPLES_SINGLE))

View File

@ -56,11 +56,10 @@ function(CREATE_TEST test_target_name test_name is_single)
PRIVATE -Wno-noexcept-type -ftemplate-depth=1024 -pthread)
if (IS_X86)
target_compile_options(${test_target_name} BEFORE PRIVATE -m32)
if(MINGW)
#set_target_properties(${test_target_name}
# PROPERTIES
# LINK_FLAGS -static-libstdc++)
set_target_properties(${test_target_name}
PROPERTIES
LINK_FLAGS -static-libstdc++)
endif()
endif()
endif()