Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Problems with std::string  (Read 2031 times)

0 Members and 1 Guest are viewing this topic.

jiyan

  • Newbie
  • *
  • Posts: 3
    • View Profile
Problems with std::string
« on: December 31, 2011, 08:30:21 pm »
Hi, i switched from SDL to sfml1.6 - everything was working fine
then i thought sfml2 would be better then 1.6, so i moved to 2

But then i see that sfml2 is using const std::string instead of const char* and my window title don't shows  what it should be.
I see som unusal characters instead of my wished titel ( things like 0z' or Oz-)

Here is a code snipped
Code: [Select]
hSF = new sf::Window(sf::VideoMode(JD_SCREENWIDTH,JD_SCREENHEIGHT,32),"TITEL",Flag,settings);
I also tried these combinations :

Code: [Select]
hSF = new sf::Window(sf::VideoMode(JD_SCREENWIDTH,JD_SCREENHEIGHT,32)std::string("TITEL"),Flag,settings);
Code: [Select]
hSF = new sf::Window(sf::VideoMode(JD_SCREENWIDTH,JD_SCREENHEIGHT,32),(const std::string)std::string("TITEL"),Flag,settings);
Code: [Select]

const std::string = "titel";
hSF = new sf::Window(sf::VideoMode(JD_SCREENWIDTH,JD_SCREENHEIGHT,32),titel,Flag,settings);


then i tried to use sf::String, it was working fine - until the end of the function. I get a stackoverflow...
The debugger shows some calls to std::allocator and the final error is thrown from "msvcr100d.dll opartor delete(void* pUserData9)"

what's the matter here?

I'm using VS2010 and shared libs (yes configured my own with cmake)

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Problems with std::string
« Reply #1 on: December 31, 2011, 08:39:41 pm »
Probably different settings in character set on the library and exe.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

jiyan

  • Newbie
  • *
  • Posts: 3
    • View Profile
Problems with std::string
« Reply #2 on: December 31, 2011, 09:04:08 pm »
All builds are using mutlibyte characters

Contadotempo

  • Full Member
  • ***
  • Posts: 167
  • Firelink Shrine
    • View Profile
Problems with std::string
« Reply #3 on: December 31, 2011, 09:10:26 pm »
Hello,
Are compiling with the correct configurations and libs? I.E. Release libs and Release type compilation on VS2010?

Also, why are you using new to create Windows? Can't think of a reason to do so.

jiyan

  • Newbie
  • *
  • Posts: 3
    • View Profile
Problems with std::string
« Reply #4 on: December 31, 2011, 09:14:14 pm »
I'm using new because i need the pointer for a global variable.

But no, i'm using the release libs with a debug config.
In sfml1.6 it worked witht his combination.

I'll try it with the right combination

[EDIT] Ok it worked :) Thank you

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Problems with std::string
« Reply #5 on: January 01, 2012, 01:39:40 pm »
Quote from: "jiyan"
I'm using new because i need the pointer for a global variable.
Very bad combination ;)

Concerning the drawbacks of global variables and singletons, I've written this post some time ago. And if you use new, you should make sure there is a corresponding delete. Or directly use smart pointers or automatic variables.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

 

anything