Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 09 Dec 2005
Offline Last Active Today, 05:17 AM

#5308448 Why can't I print out my std::string vector?

Posted by on 29 August 2016 - 05:03 AM

MapManager &MapManager::GetInstance()
  MapManager temp;
  return temp;

This is the cause of your problem.  You end up with a reference to a deleted object because the referent goes out of scope after the return statement.  Very bad.

Global variables need to be in static storage. Either make temp a static local, a cass variable, or move it out of your class entirely and make it a namespace-level variable. It's your disguising the global as something else that's hiding your problem in the first place.  Another lesson in why globals are poor practice.

#5307359 Errors that effect a computer's system.

Posted by on 23 August 2016 - 05:03 AM

Here's the most likely scenario a develop will encounter that will damage their computer irreparably.


(1) Write a program with a tight infinite loop that taxes the GPU to the maximum of its ability.

(2) Leave the program running on a laptop and go an make a soothing, relaxing mug of chai latte.

(3) Sit down and relax, inhaling the intoxicating aroma from the mug in anticipation.

(4) Pull the laptop on your lap to check how far to completion of the infinite loop has gotten.

(5) Scream in pain and jump to your feet cursing uncontrollably as the heat from the processors sears your sensitive lap flesh with second degree burns.

(6) Spill your sugary sweet and deliciously spiced chai latte all over your laptop keyboard.

(7) Watch as the laptop shuts down, never to boot again.


Sure, it's a complex series of steps but it's about the only likely way you;re ever going to fry your computer as a game developer.

#5307357 IFSTREAM: take coordinate from file and convert 3 digit coordinate into integer

Posted by on 23 August 2016 - 04:51 AM

C:\Users\Jeff\Documents\project\main.cpp|60|error: variable 'std::istringstream stream' has initializer but incomplete type

That error message usually means you forgot to include the appropriate library header before using the class.

#include <sstream>

int main()
    std::istringstream istr("100 x 300 [1]");

    int x;
    istr >> x;
    // etc....

#5305086 Ide For Linux

Posted by on 10 August 2016 - 05:50 AM

Ah, yes, the vi vs emacs game. It feels good to be back in the 1980s again, Ronald Ray-gun and electropop, skinny ties and lofty hairstyles.  Let's do tar vs. cpio next, that's another good one.

#5304649 Ide For Linux

Posted by on 08 August 2016 - 06:39 AM

QtCreator does everything in your list.  It's also the IDE recommended by Ubuntu and shipped as a part of their SDK, so you know it's supported.  I see many of the Ubuntu developers themselves using it.


Personally, I've been developing on Linux for over 20 years and never felt the need to be limited by an IDE, but to each their own I guess.

#5303074 Cross Platform Library Question

Posted by on 29 July 2016 - 05:42 AM

that's what i thought so too, like in windows, SDL uses win32 api, etc. i asked coz i thought they are using another way..


It's not just a compile-time option.  For example, on Linux, libSDL2 autodetects whether the system renderer is X11, Mir, or Wayland automatically, then instantiates the appropriate back end (by loading a DSO) to handle the required operations.  On top of that, there's an EGL layer for handling OpenGL vs. OpenGL|ES and EGL itself needs to know the native renderer and window manager for context creation.  That gives you nine possible combinations of dynamically determined back ends on Linux alone.  None of that is compile-time, although the order in which back ends are autodetected is set at compile time (and at Ubuntu we switch the order so X11 is tried last instead of first).


Other supported platforms are simpler because they have a choice of one system renderer.

#5303005 Xml Parser, C++

Posted by on 28 July 2016 - 04:19 PM

Libxml2 -- hey, it's what I've used. You asked.

#5302566 Compiling My Sdl C++ In Mac

Posted by on 25 July 2016 - 08:44 PM

Both Mac OS and Linux are POSIX systems.  Chances are good your code will just compile and run, as long as its self-contained.

#5301749 Debug With Gdb

Posted by on 21 July 2016 - 07:47 AM

The stacktrace in the original post indicates a double deletion of an object of static storage duration (ie. a global object).  The likely cause is the lack of a proper copy constructor or copy assignment operator in a class that contains pointers and inattention to the copy semantics of the objects.


A grand tool to use to analyze exactly these errors is 'valgrind'.

#5300973 Questions About Storing Opcodes With Operands

Posted by on 16 July 2016 - 06:05 AM

Back in the early 1970s I stumbled on the little gem of a CARDIAC computer, which turned me on to programming and then I learned to dig computer science in general.  If you want to learn how computers work at the opcode and register level there is nothing better, and you can join the maker set and build one yourself (complete with manual).  I still have mine.

#5300496 Getting address of an item in a std::vector

Posted by on 13 July 2016 - 05:16 AM

So from my understanding then, with the current 'shallow' copy the vector is causing the destructor to be called which is then deleting cleaning up 'memblock' making the pointer to the copy of 'memblock' invalid. This sound right?

Google 'C++ rule of three' for some greater enlightenment.

#5299911 Linux for game development

Posted by on 09 July 2016 - 04:23 PM

Redhat is also a long time player. Its server version is RedHat Enterprise, which comes with commercial support iirc. For just the software, you can use Centos (copy of Enterprise, but no (or not much) support from them). At the other end is Fedora, very close to bleeding edge. Release cycle is 6 months, life time of a release is 1 year.

Red Hat is a commercial server operating system.  Not recommended for beginners or for game dev.  The first time you run up against the mysteries of SELinux you will understand.  Or maybe not understand, which is the root of the problem.


Centos is the free version of Red Hat for people who don't want to pay thousands per year for support.  It's effectively identical to Red Hat, and owned by Red Hat, but you get zero support.  Many less expensive ISPs run Centos in their server farms.


Fedora is the desktop version of Red Hat, run by an arms-length community sponsored by Red Hat.  It tends to be more leading-edge and is used as a testing ground for new technology and software before it lands in Red Hat.  It uses Gnome Shell as the UI, which is backed primarily by Red Hat.


SuSE is another enterprise-oriented distro.  It used to be Novell before Microsoft turned their attention to networking.


Debian is a purely volunteer-run general distribution, mostly focused on server because that's where most of the volunteer's interests lie.  It's not an organization per se, it's more of an anarchy that offers downloads and the occasional sneer if you ask for help.


Ubuntu is roughly based on Debian, but with more testing (many Debian packages are patched for Ubuntu to fix bugs found in testing).  It has a commercial company sponsoring it (Canonical), which also sponsors various community help channels.  Also has a server edition and runs on phones and tablets. There are some official flavour of Ubuntu that sport different default UIs (eg. Ubuntu Gnome, Kubuntu (KDE), Lubuntu (LXDE), Ubuntu Mate).  Generally works out of the box except you have to install closed-source codecs and drivers explicitly because distributing them together with Free software is of questionable legality.  Companies like Valve and Google use Ubuntu internally and Canaonical regularly works with Intel, AMD, and nVidia to keep their video drivers working.


Mint is a popular rebranded Ubuntu with either the Mate desktop or the Cinnamon desktop and bundled with commercial codecs and drivers.  They usually refer you to Ubuntu for help.


Arch is popular among the set where it's popular to measure the size of your hard drive in public change rooms.  Many users have unbridled enthusiasm about their choice of distro.


I would recommend, if you're a beginner, to stick with either Fedora, Ubuntu, or Mint.  They're generally stable and well-tested and have active, welcoming (mostly) communities and user support.


Disclaimer:  I work for Canonical and develop parts of Ubuntu.  I also contribute to Debian.

#5299885 sort list

Posted by on 09 July 2016 - 09:25 AM

I get this error:
Multiple markers at this line
    - ‘test2’ was not declared in this scope
    - expected primary-expression before ‘&’

'test2' was not declared in the scope. The error message is not ambiguous. You can not just take the address of an undeclared variable like that.

What you want to do is pass the function itself, not call the function.


#5297969 Have I been aged out of the industry? And where else can I go?

Posted by on 25 June 2016 - 05:26 AM

It's not your age (you're way younger than me).  You just need to get that depression under control, nobody needs that around the workplace, and trust me, interviewers see it right away.

#5297919 Is there any reason to prefer procedural programming over OOP

Posted by on 24 June 2016 - 03:25 PM


He is certainly entitled to his opinion but in my opinion the standard library contains a lot of what I would consider 'modern OO for C++' (while not 'classically taught OO' which nowadays often feels to me like the 'bad OO' anyway).

Do you have any examples?  Certainly most of the container classes seem very non-OO to me.  Vectors don't know how to iterate over themselves.  Rather, the algorithms to do things with vectors are kept at arms length and divorced from the containers.  That's not in the slightest how OO designs tend to work.  In fact, it's the complete opposite.  OO is about coupling code and data.  The C++ containers are all about decoupling code and data.  Much of the standard library following the STL stuff has followed a similar pattern.


Howsabout <random> and <regex>? <iterator>? <functional>? <string>??? <mutex> and all the threading stuff?