Jump to content

  • Log In with Google      Sign In   
  • Create Account

Calling all IT Pros from Canada and Australia.. we need your help! Support our site by taking a quick sponsored surveyand win a chance at a $50 Amazon gift card. Click here to get started!


Member Since 09 Dec 2005
Offline Last Active Yesterday, 01:42 AM

#5217325 C++ do while error

Posted by Bregma on 18 March 2015 - 06:11 AM

You have an executable statement at namespace level.  That's just not a thing in C++.

#5216424 Question About Port assignments

Posted by Bregma on 14 March 2015 - 06:35 AM

I guess if you're using UDP there might be a slight advantage to doing multiple server ports like this, but with all the complex code and hassle involved in port forwarding and the security implications involved in opening up all your ports on your firewall, it doesn't sound worth it over having a single port that hands off an accepted TCP connection to the room.  On Linux you can even pass open socket file descriptors to separate processes over IPC if you've partitioned your server that way (dunno what platform your server is running on).

#5216245 non-uniform random numbers (triangle distribution and more)

Posted by Bregma on 13 March 2015 - 04:50 AM

Just an aside: the C++ standard library has about a dozen non-uniform random number distributions, both continuous (well, real-valued) and discrete. A good place to go to for ideas because it has all the widely-used basics (Gaussian, Bernoulli, gamma, etc).

#5216026 Template not linking?

Posted by Bregma on 12 March 2015 - 04:50 AM

Where is this mysterious s_Instance defined?

#5215402 GUI Challenge

Posted by Bregma on 09 March 2015 - 06:22 AM

The only time you may run the project is once you believe it is done

This reveals you are not a developer, because a developer knows no program or asset is ever really truly done.  If you're not a developer, you're from sales so you're gonna get downvoted to oblivion.

#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.