Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 09 Dec 2005
Online Last Active Today, 11:32 AM

#5214931 makefile

Posted by Bregma on 06 March 2015 - 05:50 AM

You only need to force the toolchain to build for an x86_64 target if you're not on an x86_64 host (ie. you're cross building).  It's probably much simpler to just remove the -march flag from the compiler command than to keep adding more cross-building flags to other parts of the toolchain in order to get a native build.


I imagine the -march=i686 was added to the original Makefile to prevent builds for Pentium II or earlier CPUs which did not support certain faster instructions.  The x86_64 architecture does not need to be restricted to processors available only in the last decades since all of them quallfy in that respect.

#5212583 How were you learning programming at the age of 5?

Posted by Bregma on 23 February 2015 - 06:29 PM

Were you hacking calculators at that age?

Electronic calculators hadn't even been invented when I was that age.  I do have memories, however, of using a slide rule at age 5 to help my mother (a science teacher) calculate grades for her class.  There's something about manipulating things given a particular input and having the output just appear that is just like programming.  Just like it.  So when my mother brought home a CARDIAC a couple year later it was easy to make the leap.


My kids at age 5 could barely use a mouse to make Reader Rabbit identify patterens.  Now of course they can text and google and download illegal content like any other young adults or teens, and my younger daughter can frag evil guys and zombies with the best of them, but nobody in my house has ever show any desire to make electrons dance.  Hashtag sadface.

#5210453 Operator Overloading C++

Posted by Bregma on 13 February 2015 - 05:50 AM

Firing back...

//Operator+ (refactored to trip up JPs)

MyObject operator+(MyObject lhs, MyObject const& rhs) {
    return lhs += rhs;

#5210451 Aliens as citizens of the Empire?

Posted by Bregma on 13 February 2015 - 05:45 AM

Don't forget the interesting aspect of what happens even within the superior race(s) of your empire.  Refusal to airdrop the disease-infested blankets on colonized planets; citizens caught selling intoxicating rocket fuel to lesser species on the reserved wasteland left to them on their native planet;  breakaway planets forming an alternative federation and eventual civil war over freeing the slave races; million-lightyear marches over the lack of civil rights for the disenfranchised species; organized crime including intoxicant running and illegal planet-hopping among the second-tier species; space police violence and subsequent species riots; lynching poor refugee insectoids from their own spinnerets after accusations of stealing your women, etc.


Maybe you're just better off wiping out every alien species where you find it.

#5208414 An invalid iterator that is null while checking collision detection

Posted by Bregma on 03 February 2015 - 10:02 AM

Do not use for(it) and erase(it) in the same loop.  You will know grief.

#5208380 Comparison of STL list performance

Posted by Bregma on 03 February 2015 - 06:15 AM

o me it sounds a bit too much that std::list would use additional "next" and "prev" pointers for every element, when it could speed up performance simply by using buckets.

A std::list that invalidates iterators after erase() or insert(), and does not support remove() and splice() as defined in [], would be non-conforming.  If you want a deque, use a deque.

#5207918 How to import a custom module?

Posted by Bregma on 31 January 2015 - 01:29 PM

Python does not know where to find the module you're trying to load.  It normally only looks in the configured system installation path, and that depends on a number of factors (given you're running KDE my guess is you're on Linux, so I'll point out it depends on the Python version and the distro you're running).


To add additional search paths for importing modules when running Python, use the PYTHONPATH environment variable.  In your Konsole shell, try


  PYTHONPATH=~/pythonpractice python


This is assuming you have a file called ~/pythonpractice/pyperclip/__init__.py (which is the file Python will be looking for when you import pyperclip).

#5205977 Encapsulation through anonymous namespaces

Posted by Bregma on 22 January 2015 - 07:03 AM

BTW, it's the same as:

Not entirely: there's an important difference between names with static linkage and names with extern linkage. For example, templates can only be instantiated with names of extern linkage. Names with extern linkage get involved in link-time resolution, names with static linkage do not (so giving things static linkage where possible can speed up build times, sometimes remarkably).

Names at namespace level (including the :: namespace and the anonymous namespaces) by default have extern linkage. Adding the 'static' keyword gives them static linkage instead.

Still, it is the traditional C way of encapsulating things, used since the early 1970s. There are worse things to reinvent.

#5205566 c++ Heap corruption w/ std::vector

Posted by Bregma on 20 January 2015 - 10:24 AM

What is the smallest, simplest program that reproduces the error for you? The code you posted contains no errors, we can't guess at the code you did not post.

#5205290 why C++?

Posted by Bregma on 19 January 2015 - 08:29 AM

The answer is at your fingertips.

#5205012 Porting my game to Linux

Posted by Bregma on 17 January 2015 - 10:00 PM

While I'm at it, Ubuntu has an app store, and I hear that it's not working (or harder than it should be to install) on Linux Mint 17. One of my goals is to get this on that distribution channel. Do Mint users commonly have this installed?

The Ubuntu App Store only distributes Ubuntu click packages for the Ubuntu phone (it's actually pretty easy to get your app there, but not (yet) applicable to the Ubuntu desktop).  It might be you're thinking of the Ubuntu Software Center, which is just a GUI front end to the Ubuntu software archives (whence most software for Ubuntu and Mint comes).  Getting your software into the Ubuntu archives might be a little tricker:  it has to pass several technical and social challenges first.  They also prefer you get it into the Debian archives first, and that's a major challenge given the tight clique circle-jerk that is Debian.


Keep in mind most distros will build the binaries for your application from source: you only have to worry about "working on other distros" if you're distributing binaries.  If you're distributing binaries, you're not going to get in to the equivalent of an app store for a distro.


Also, Ubuntu accounts for about 80% of all installed Linux desktops out there, and Mint is just a copy of Ubuntu with the thin veneer of a different desktop shell lacquered on top.  Targeting Ubuntu 14.04 LTS is probably all you need to worry about.

#5203676 About computer instruction in relation to RAM consumption

Posted by Bregma on 12 January 2015 - 09:19 AM

Although it may look attractive to jump into the deep and quickly get a feel of moving towards your dream, it will not help you to actually become a proficient game programmer. That's why I always - sometimes against popular belief - recommend to start out with raw assembly (preferably on a 65xx emulator or DOS in real mode) and then move up to C or any other compiled language, and finally move to scripted languages. That way you can see all the way down at any stage and really know what's going on under the hood.

You have not learned to appreciate how computers work until you have smelled the rosin core of your solder.


Seriously, there are really good hands-on ways to understand the basics of a computer.  Be forewarned, this can be a (worthwhile) time an money sink.

#5202603 Silly question about classes/libraries/headers

Posted by Bregma on 07 January 2015 - 09:00 AM

The technical term in C++ is "namespace-level function".  It's often colloquially known as a free function or a non-member function, both terms implying the normal state for a function is as a member of a class.  It is an untrue assumption.


The technical term in C is "function".


The technical term introduced by FORTRAN well over 60 years ago is "subroutiune."


The technical term for moving a namespace-level function into a separate .cpp file is "separate compilation."

#5202219 Looking for a good way to make games in C/C++ on linux for cross-platform

Posted by Bregma on 06 January 2015 - 07:30 AM

what is the best way to distrubute after i make a game in C++


(1) Both libSDL2 and SFML are available on popular GNU/Linux OSes and have been ported to the Mir display server and the Weston API for Wayland, so they'll continue to be available on future iterations of those OSes.


(2) The way to distribute software on most popular GNU/Linux OSes is via software packages (generally either RPM or DEB format), and packages generally need to be targeted at a particular OS.  Some newer package formats (eg. how Steam works) are now being supported that are more cross-platform because you ship and install all the dependencies in one huge, expensive-and-slow-to-download tarball.  Generally, licensing and security issues get ignored with the latter, so be prepared for problems down the road.


I'd say first get your game working, then worry about distribution.

#5201824 Linking Words as Conditional Statments

Posted by Bregma on 04 January 2015 - 05:28 PM

I suspect you're trying to map natural language constructs into programming language constructs, because apparent some computer programming languages use tokens identical to natural language words to identify mathematical processes or operations not terribly unlike those denoted by the natural language word they mimic.


The problem is that it is not an ontological relation between the vocabulary of a natural language and the underlying mathematical concepts denoted by a programming language.


Don't be mislead by the superficial resemblance between programming languages and natural languages.  The likeness is not coincidental, but is about as meaningful as using invisible whitespace to give significant meaning to program code.


If you want to look at an attempt to give a natural-language-like semantic veneer to a programming language, read up on COBOL.  It was supposed to be so natural to use any non-engineer to whip up a bank payroll or military missile guidance system without introducing any errors at all, and be able to explain it to his pointy-haired boss..  "ADD ONE TO ACCOUNT-INDEX GIVING NEXT-ACCOUNT-INDEX.  MOVE PAYROLL-RECORD AT NEXT-ACCOUNT-INDEX FROM INPUT-FILE TO WORKING-PAYROLL-RECORD."  Go wild.