Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 09 Dec 2005
Offline Last Active Today, 12:57 PM

#5147380 c++ oo syntax behind the scenes behavior

Posted by Bregma on 16 April 2014 - 10:29 AM

If you add more virtual functions, the class size does not grow though.

That can be a little misleading.  The size of objects (class instances) does not grow, but the vtable size changes, and maybe even its layout changes.  That's important to know, because it's an ABI change and the not infrequent cause of subtle and inexplicable runtime failures.


This sort of thing shows up as a problem if, for example, you add a virtual function to a header file and rebuild a program, but do not rebuild a DLL that also uses the header file.  Bam!

#5146378 I have some new habits.

Posted by Bregma on 11 April 2014 - 01:34 PM

Now, how would you express units in programming where you could also convert between them?

If you're using C++, user-defined literals are the way to go.

#5146377 What path to take in programming?

Posted by Bregma on 11 April 2014 - 01:27 PM

Don't assume you get job training, get a job, then retire and die.  Life is short: make it wide.  Stay in school, get a broad and unfocused education.  Learn.


I graduated some time ago, and I'm now working in a field and using technologies that weren't even dreamed of when I was in university.  Focus now on learning as much as you can about as much as you can, worry about the job training you'll need in your just when you finish your education and the job you fall in to has been created.

#5145142 Duel or Multi-boot Operating Systems - Windows OS

Posted by Bregma on 07 April 2014 - 01:21 PM

It is my experience that multi-boot is a cheap solution, and that getting dedicated hardware for the job is better if you can afford it.  If you're doing this professionally, don't waste time with multi-boot systems.


Multiboot systems work.  Dedicated systems work better.

#5143547 Linux development...

Posted by Bregma on 31 March 2014 - 01:43 PM

OH btw how are you all finding these libs to add to the development kits? I am lost on these...

package manager (apt-get irrlicht-dev)

You're using Mint, which is based on Ubuntu, which is a Debian derivative. Debian uses the "deb" package format -- a standard way of packaging software and declaring all the necessary dependencies.

Unlike, say, Windows in which there is no such thing as a standardized way of distributing software, most Linux distributions stick to providing all software in a single way (although different distros use different ways -- there is no "there" there in GNU/Linux).

On a Debian-derived system, the package is the "deb" and there are several tools to use debs. The most fundamental one is "apt" and you'll see instructions for downloading and installing packages from the command line using the "apt-get" command. The apt-get command will select a named package from your configured sources and download that package and all other packages required to make it work, and install them. If you always use this tool, your system will never get in to a broken state.

If you start up your Mint system, open a terminal, and type "sudo apt-get install libirrlicht-dev" the system will find, download, and install the Irrlicht development package (which contains header files and link libraries) and the libirrlicht1.8 package (the runtime DSOs, or shared libraries) required to develop against Irrlicht. You can see more information on that package by using the command "apt-cache show libirrlicht-dev", and you can see what files were installed using the command "dpkg -L libirrlicht-dev".

The installation command must be run as the superuser (a privileged administrative user) because it installs the packages system-wide. That's what the 'sudo' command does.

These are all basic commands you just need to learn. There is a learning curve for any system, including the one(s) you already know. It's no harder to do things on a GNU/Linux system than on any other system, don't let your prejudgement fool you.

Tip: to find other development packages, for example, the SDL2 packages, use "apt-cache search libsdl2" to search. The standard Debian naming convention is to prefix a library package with "lib" and suffix a development package with "-dev".

#5143522 Linux development...

Posted by Bregma on 31 March 2014 - 11:32 AM

I need some recommendations for IDE under Linux.
QtCreator? If I remember right the UI wasn't to friendly to get a simple C++ project working....

I think you're probably mistaken. Try it.

How do I install the latest drivers for this GPU? From what I can tell the latest don't support the X1300?

I don;t know much about Mint, but they'll have the command line available to you from which you can just do an "sudo apt-get update; sudo apt-get upgrade" and that will make sure the latest tested drivers are installed. I strongly recommend using drivers that have not been tested and packaged in the Ubuntu archives, that's a good way to brick your system if you're not an expert.

What is X11? Do I need it?

X11 in this context is the display server: it's the software responsible to drawing everything to your video screen. You don't need it: most servers run without video displays. If you want to make graphical games, however, you will probably want it.

I would like to use Irrlicht also but couldn't get that working either.

That's a little vague. Perhaps there are errors or something?

So I am not liking the experience so far... Not trouble free at all....

Here's quick rule of thumb: get everything from your distro unless they don't have it. If they don't have it, as a beginner, you probably don't need it yet.

Hope to overcome the sour taste of this and enjoy coding on Linux but need some serious help!!!

Welcome to the dark side. We have the answers.

#5142977 MSVS's preprocessor vs gcc's preprocessor

Posted by Bregma on 28 March 2014 - 08:30 PM

Bregma, on 26 Mar 2014 - 2:15 PM, said:

I think the header files may be set up to build under MSVC, so the #ifdefs may be set incorrectly. What if you add -DGLAPI to the command line?

When I did that I got this but I don't know how to send all my errors to a file. I know how to use fprint in c to send output to a file but I don't know about errors:

I googled how to redirect stderr and stdout in the DOS command line for you.  I'm not sure if you're using the DOS command line or a POSIX-style shell (like MinGW32), but either way they're the same: >out.log 2>&1.  You put that at then end of your compile command to capture the diagnostics.  Can be a lifesaver.


From your description I really suspect there is a different set of predefined macros supplied by the different compilers, and that some header file is making an invalid assumption about the meaning of them.  You plan of attack should be to grep (search) through all of the header files to find one (or more) line(s) where GLAPI is #defined, then figure out which combination of macros is required to get it defined correctly.  It is normal for different compilers to have different sets of predefined macros; it's one of the things that makes preprocessing actually useful.


You can get a list of predefined macros from GCC using the -dM switch (from the GCC manual: touch foo.h; cpp -dM foo.h).  I seem to recall MSVC has a similar thing.  I suspect the culprit may be something like #ifdef _WIN32 used incorrectly (but don't quote me on the macro, it's just an example).


Good luck.

#5142362 MSVS's preprocessor vs gcc's preprocessor

Posted by Bregma on 26 March 2014 - 12:15 PM

I think the header files may be set up to build under MSVC, so the #ifdefs may be set incorrectly. What if you add -DGLAPI to the command line?

#5142178 MSVS's preprocessor vs gcc's preprocessor

Posted by Bregma on 25 March 2014 - 07:45 PM

#include <GL/glut.h>

Make sure your -I switch points to the folder containg the GL folder.  For example, if the glut.h file is in F:\school\csci\opengl\SB5\Src\GLTools\include\gl\glut.h then the command-line argument needs to be -IF:\school\csci\opengl\SB5\Src\GLTools\include .. just in case it was not clear.  It really is important to see exactly what the error message is.


Also, I'm not sure what environment you run in, but it's usually possible to capture all diagnostic output into a text file for later analysis.  In the environment in which I work, adding '>build.log 2>&1' works, but if you're using an IDE surely there is some equivalent.

#5142140 MSVS's preprocessor vs gcc's preprocessor

Posted by Bregma on 25 March 2014 - 05:18 PM

Can you try adding -DGLAPIENTRY to you GCC command line?

Also, find the errors at the top (beginning) of the error output, I suspect there may be a message about file not found. The GCC preprocessor may not like the bell character used like that.

#5141734 Continuous Play Experience

Posted by Bregma on 24 March 2014 - 11:01 AM

...could all be turned into a game because you can make it competitive and more easily tracked by people.

Wasn't that a ST:TNG episode? Use a personal-electronics video game as a vector?

I can imagine the big brother NSA-style implications.

#5141521 "Vector" of types? (compile time template)

Posted by Bregma on 23 March 2014 - 02:26 PM

You need to read Alexandrescu's "Modern C++ Design." It's a little dated now (it was written to the 1997 C++ standard) but it will still work with modern compilers. It spend most of its bulk dealing with template typelists.

#5140956 ling obj+obj to obj and 'where headers'

Posted by Bregma on 21 March 2014 - 08:15 AM

I got a set of many obj (.o) files can I link them into other biger obj
file? (as an intermediate step later I will be linking this bigger obj's into exe)

Yes, at least with a link format like ELF, but it's generally not done. Usually if you want to group compiled .o files into a single "bundle" you use a static library. Everything is set up to support that, and it works with all link formats.

I got some header "all_headers.h" file containing references (includes) from all my header files (i know its bad name but I cannot find some better)
If I want to add it to my files I could use relative like
#include "..\all_headers.h"
#include "c:\code\all_headers.h"
but both are somewhat wrong

It's wrong on 2 levels: (1) it's wrong because '\a' and '\c' are not valid characters to include in pathnames, and (2) using relative paths is bad practice becuase it makes work when you refactor your project, and it's not necessary. Certainly hardcoding the drive name into a path is going to bring you grief sooner or later.

It's not unusal to namespace headers, which uses paths relative to the top of a source tree. Relying on platform-specific behaviour like the dot-dot directory being the parent of the directory in which the current source file is found will break.

could I just include
#include "all_headers.h"
#include <all_headers.h>
and make precompiler to find it? (but i dont wont to copy this all_headers.h
out of my source folder to increase dependency confusion just to inform
compiler where ha can search for it ?)

Yes, that is how things are designed to work. The command-line switch for extending the search path for header files is -I (upper-case letter "i").

#5139092 Computer Science vs Software Engineering

Posted by Bregma on 14 March 2014 - 05:03 PM

...remember those degrees only teach you a small fraction of what you need to know out there.

Yes, indeed.  If you think a degree provides job training, you've already failed.  Go take a year off and backpack through Europe or Southeast Asia, you will learn a lot of what you need to know out there.  When you come back, reconsider your options, and if what you want to do is learn a lot about something and grow from the sheer joy or learning and knowledge, go get a degree.  They're not for everybody and it's possible to live a fulfilling life and contribute constructively to society without one.


And, it really doesn't matter what degree.  Some of the most accomplished people I've worked with in the software industry have a degree in physics or English literature.  Most of the good programmers, though, have a CS degrees because that's what tickles them most.  I've worked with a few people without degrees: someone needs to answer the phone at the front desk and someone needs to be on-call in the IT department.

#5138384 Chained functions in C

Posted by Bregma on 12 March 2014 - 06:52 AM

I think it's nonidiomatic, hard to read, and far too Klever™.
The idiomatic way to chain functions in a C-based language is to return a pointer or reference to the object.


That way, the order of operations and the textual ordering are the same.  In C proper, the traditional way accomplishes the same thing.
You write programs for human readers.  If you try to make it harder for them (and "them" is more likely "you" a few months later), you're just being an ass.