Jump to content

  • Log In with Google      Sign In   
  • Create Account

Bregma

Member Since 09 Dec 2005
Online Last Active Today, 04:39 AM

#5301749 Debug With Gdb

Posted by Bregma 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 Bregma 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 Bregma 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?

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




#5299911 Linux for game development

Posted by Bregma 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 Bregma 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.

Ausfalllinie.sort(compare);




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

Posted by Bregma 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 Bregma 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?




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

Posted by Bregma on 20 June 2016 - 06:55 AM

OOP is a way of organizing procedural programming so that you can focus your reasoning on the complex interactions between large sets of data and rules.  It's not like they're mutually exclusive, since they actually address different domains of thought.

 

The expensive part of successful software development is the time spent reasoning about things (and recovering from poor reasoning, or coming up to speed on old or someone else's reasoning).  OOP helps reduce that cost when using procedural programming.  Some procedural programming languages laud that enforce a particular way of thinking about OOP via their restrictive syntax, which is designed to make things more code-monkey friendly to reduce costs.




#5297045 Object created in one class, needs to use variables in the class it was creat...

Posted by Bregma on 17 June 2016 - 05:15 PM

Have the MainGame update itself based on state reported by the Input object?

 

Have the MainGame register callbacks on the Input object so the Input object can ask the MainGame to update itself?

 

Use a message-passing protocol to communicate state between object?




#5296213 Trivially trivial?

Posted by Bregma on 12 June 2016 - 07:23 AM

The way the standard library was designed, and I would suggest trying to fight against the way it was designed will send you on an increasingly downward spiral, is to overload std::copy() for your class.

 

You should rely on std::copy() being used in an algorithm or container, knowing that it will call std::memcpy() for trivially-copyable objects and the copy constructor/move constructor/operator=() for non-trvially copyable objects, and your override of std::copy() can just call std::memcpy() if you have an object that you know is trivially copyable but the compiler can not deduce it on its own.  Most times, the compiler will do the right thing (even if you think you know better), and making it explicit that you're overriding the default compiler behaviour by supplying a std::copy() overload documents you decision, just like using a cast.  You are after all trying to communicate to the human reader that you're doing something unexpected and that you know better in this particular case, as opposed to just telling the compiler to do something.

 

You are explicitly allowed to overload std::copy() for just that reason.  In the std:: namespace no less.  Just like the big boys.




#5293575 Do you usually prefix your classes with the letter 'C' or something e...

Posted by Bregma on 26 May 2016 - 07:21 AM

You write code for humans to read, it's a work of literature.  To that end, semantics and readability are paramount.

 

Pyou vshould pnot vprefix nwords pwith aartificial aencoded pplanguage pconstructs aany amore cthan pyou vshould vdo pso pwith ahuman nspeech.  Pit vdoes pnot venhance nreadability.




#5293192 Is there a way to change initialisation order while keeping object layout ?

Posted by Bregma on 24 May 2016 - 06:39 AM

The committee had to choose some rule for initialization order.  The chose the one that will work reliably under all situations:  with the presence of explicit initialization or without.    I suppose the could have gone with "in the order of explicit initialization except when some explicit initializers are missing in which case you fall back to member declaration order and except when there is non-virtual multiple inheritance with differing base class constructor calls and also not in plain-old-data copy constructors or any classes derived from them and, well, there is no guarantee about default copy operators ever doing the right thing any more" but my guess is they thought that might be a little more error-prone and liable to unexpected behaviour.




#5292600 My C++ gotcha of the day

Posted by Bregma on 20 May 2016 - 04:32 AM

I expected for SFINEA to eigther give some compilation error that the class was not defined at this point, but not just silently tread it as if it was an empty class the whole time.


Huh. Any idea what SFINAE stands for? It should be a clue as to why it's unreasonable to expect an error in that situation.


#5291536 What book to start from

Posted by Bregma on 14 May 2016 - 05:33 AM

The book you should start with is your netbook.  By that, I mean start writing code.  It doesn't have to be good code, it doesn't have to work perfectly, but it's gotta be code and you have to write it.

 

Passive learning from a paper book is not nearly as effective as JFDI and see what happens.  Bits are cheap, use as many as you want.




#5290397 Is it real?

Posted by Bregma on 06 May 2016 - 06:07 AM

How long would it take to make something at the scale of Dragon Age Origins, if i already have all the assets (models, audio, arts etc.) and i'm using unreal engine? How long would the coding and uniting everything part take?

About the same time as it would take to make a movie like Star Wars VII: The Force Awakens if you already have a couple dozen actors lined up, a beach ball, and a really nice prosumer DSLR camera.






PARTNERS