Optional parameter to signal "MousePressed"

Started by AlexxanderX, 28 January 2015, 09:54:37

AlexxanderX

Quoteobj/Handler.o: In function `ZN4tgui12extractTypesIIN2sf7Vector2IfEEEE6getRowEv':

D:/Programare/Libs/TGUI/include/TGUI/Signal.hpp:71: undefined reference to `std::string tgui::convertTypeToString<sf::Vector2<float> >()'
collect2.exe: error: ld returned 1 exit status

From what I read on the 0.7-dev documentation the signal "MousePressed" can have an optional parameter sf::Vector2f position, but I don't know how to use it because I'm receiving the above error from using this code:
m_windowTiles->connect("MousePressed", [this](sf::Vector2f position){ m_map->removeLastTile(); });

texus

In a simple piece of code that I used, the following works fine:
Code (cpp) Select
button->connect("MousePressed", [](sf::Vector2f position){});

What compiler are u using?

AlexxanderX

I have tried using mingw-w64 4.8.2 (i686-4.8.2-posix-dwarf-rt_v3-rev3) and mingw-w64 4.9.1 (i686-4.9.1-posix-dwarf-rt_v3-rev2) but same error.

texus

You get the same error when you use this instead of your line?
Code (cpp) Select
button->connect("MousePressed", [](sf::Vector2f position){});

What about this one? (it would give an error on runtime, but it is just to check if it compiles)
Code (cpp) Select
button->connect("MousePressed", [](int i){});

And what if you put this somewhere in your code?
Code (cpp) Select
template <> std::string convertTypeToString<sf::Vector2f>() { return "sf::Vector2f"; };

AlexxanderX

For the first line I received same errors.

For the second I receive:
Quoteobj/Handler.o: In function `ZN4tgui12extractTypesIIiEE6getRowEv':
D:/Programare/Libs/TGUI/include/TGUI/Signal.hpp:71: undefined reference to `std::string tgui::convertTypeToString<int>()'
collect2.exe: error: ld returned 1 exit status

And for the last one I putted like this out of my class:
namespace tgui
{
template <> inline std::string convertTypeToString<sf::Vector2f>() { return "sf::Vector2f"; };
}

And worked. Thanks for the workaround fix.

texus

It seems like the functions in Signal.cpp are not marked for being exported. Which is why it works on everywhere except on windows when using dlls.

It should be fixed in the latest version, but you can of course just keep using the workaround for now (as long as you delete that code when you ever update to a newer version).