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

Author Topic: Moving source code made in Windows to XCode on Mac Errors  (Read 3120 times)

0 Members and 1 Guest are viewing this topic.

davidsomen

  • Newbie
  • *
  • Posts: 3
    • View Profile
Moving source code made in Windows to XCode on Mac Errors
« on: February 18, 2011, 03:41:30 am »
I moved the source game for a game I'd created in Visual Studios in Windows to XCode on mac but for some reason I'm getting these errors that I never got in windows :S

'sf::NonCopyable::NonCopyable(const sf::NonCopyable&)' is private
within this context
synthesized method 'sf::Thread::Thread(const sf::Thread&)' first required here
synthesized method 'sf::SoundStream::SoundStream(const sf::SoundStream&)' first required here
synthesized method 'sf::Music::Music(const sf::Music&)' first required here

Can someone explain what the errors mean please

Lalaland

  • Newbie
  • *
  • Posts: 4
    • View Profile
Moving source code made in Windows to XCode on Mac Errors
« Reply #1 on: February 18, 2011, 06:41:52 am »
The errors indicate that you are trying to copy the non-copyable class of sf::Music, and then  fails to copy the classes sf::Music is derived from.

davidsomen

  • Newbie
  • *
  • Posts: 3
    • View Profile
Moving source code made in Windows to XCode on Mac Errors
« Reply #2 on: February 18, 2011, 11:53:43 am »
What's the solution :S Why is this an error here if it wasn't before

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Moving source code made in Windows to XCode on Mac Errors
« Reply #3 on: February 18, 2011, 12:11:35 pm »
Quote
What's the solution

Don't copy sf::Music instances. Use pointers if you can't get rid of copies.

Quote
Why is this an error here if it wasn't before

It's always been an error. If you didn't get it before, it's because you never copied sf::Music instances (or either because you were using a really weird compiler).
Laurent Gomila - SFML developer

davidsomen

  • Newbie
  • *
  • Posts: 3
    • View Profile
Moving source code made in Windows to XCode on Mac Errors
« Reply #4 on: February 18, 2011, 01:45:02 pm »
It was just visual studios default compiler last time :S

Can you give me an example of how I might of copied it and how I'd use a pointer instead please. Thanks for you help

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Moving source code made in Windows to XCode on Mac Errors
« Reply #5 on: February 18, 2011, 01:53:42 pm »
Quote
It was just visual studios default compiler last time

Ok, so you definitely had the error before, too.

Quote
Can you give me an example of how I might of copied it and how I'd use a pointer instead please

Right now you're doing this kind of things:
Code: [Select]
// either...
sf::Music music;
music = sf::Music(...); // --> copy there

// or...
std::vector<sf::Music> musics;
musics.push_back(sf::Music(...)); // --> copy there

The solution is to avoid these copies if possible. For example, reuse the same instance if you change the music, instead of creating a new one.

If not:
Code: [Select]
// either...
sf::Music* music;
music = new sf::Music(...);

// or...
std::vector<sf::Music*> musics;
musics.push_back(new sf::Music(...));


I can't be more relevant without knowing what you do in your code.
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Moving source code made in Windows to XCode on Mac Errors
« Reply #6 on: February 18, 2011, 01:55:08 pm »
What you may not do, is calling the copy constructor or assignment operator.
Code: [Select]
sf::Music music;
sf::Music music2 = music;   // copy constructor
music2 = music;             // copy assignment operator

Often, copies are more hidden, for example at parameters or return types.
Code: [Select]
sf::Music Function();
void Function(sf::Music music);

Apart from that, you cannot store noncopyable objects in STL-Containers.
Code: [Select]
std::vector<sf::Music> vector;
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: