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 08 Aug 2000
Offline Last Active Today, 02:35 PM

#5178704 Base Class Undefined

Posted by BitMaster on 07 September 2014 - 11:00 AM

How does VS choose which CPP file comes next?  Is it alphabetical?

When you build your project there will usually be a window with the compiler output in the bottom. If you want to, you can read the sequence things happen out of there. However, that is not going to be relevant for your problem.
It would really help to post the relevant code (for example where is characterclass actually defined) instead of screenshots as well as complete error messages.

If there are 3 header files in a file, will it immediately do all of those headers next?  I only have one header in each CPP file (the H file by the same name) but the headers may have 2 or 3.

Headers are irrelevant. The compiler only deals with .cpp files and an #include directive is just a convenient automatic way to paste the complete content of whatever file is referenced there. That happens during preprocessing before the compiler even sees it.

The most likely issues are that you did not include the header which declares characterclass or your inclusion guard did not use a unique enough define. Note that using '#pragma once' instead of manual inclusion guards would solve this problem immediately and is available on all three compilers an average person is likely to encounter (MSVC, gcc and clang).

On a more serious note, avoid 'using namespace' directives in headers. If you really need to, do that in implementation files or at function scope.

#5176001 So... C++14 is done :O

Posted by BitMaster on 25 August 2014 - 08:38 AM

I have to agree with SmkViper and disagree with Samoth. No compiler will actively insert a formatHardDrive() but all you need is to call an uninitialized function pointer. The address just has accidentally match the address where the corresponding OS function is mapped to. Your call stack might look just right. Likely? Nope. Extremely unlikely? Yes. But still theoretically possible? Yep.


I actually have personal experience with something a bit like that. Sometime in 97/98/99 when I was young and learning and inexperienced I was crashing my DirectX applications with undefined behavior. At some point I couldn't get anything to work even when reverting to a known workable state. I decided to call it a night and try it fresh again tomorrow. Long story short, after banging my head against a couple of walls I noticed several DirectX DLLs had a rather peculiar size: 0 bytes. And I wasn't even doing anything with file IO.


Granted, something like that is unlikely to happen on modern operating systems, but a surprising amount of crap can/could still happen with undefined behavior.


And even setting all of that aside, the "could format your hard drive"-story is mostly hyperbole to catch attention. A lot of people coming here with undefined behavior problems don't recognize what kind of problem they are in and then post something like "I just switch those two variable declarations and the problem went away. Thanks guys." and then complain when people don't stop talking about their (still existing, just currently hidden) issue.

#5174051 pointer value

Posted by BitMaster on 16 August 2014 - 01:43 AM

You are invoking undefined behavior (you are writing to an uninitialized pointer) and that will either crash or screw up a random part of your program (very bad because it might remain undetected for a very long time and when it starts crashing it will be days to track down the issue).


For this situation the solution would probably be:

float pin28Value = 0.5f;
XPLMSetDatavf(pnlBri, &pin28Value, 10, 1);

#5173796 Cannot Clear/Draw to Framebuffer

Posted by BitMaster on 15 August 2014 - 12:14 AM

No, that is not an explanation. To know that OpenGL would have to look into the future.


Looking over your code I notice you did not set GL_TEXTURE_MIN_FILTER and GL_TEXTURE_MAG_FILTER with glTexParameteri. My last manually created framebuffer is a while ago now but I believe I remember these need to be set for a texture render target. Is it possible you added these calls when you implemented the obejct rendering code?

#5172303 Thread-safe weak pointers

Posted by BitMaster on 08 August 2014 - 09:57 AM

It feels a bit weird that you need to copy them so much that it actually matters. Are you certain you are using const references or move semantics where possible?

#5171811 Boost serialization exception problems

Posted by BitMaster on 06 August 2014 - 03:10 AM

I have limited experience with boost::serialization but I would probably start by reducing the amount of work you do in the serialization function to home in on exactly which type is causing the issues. Once you know what exact type is causing the problems it should be much easier to figure out what goes wrong.

#5171804 Sharing OpenGL Buffers Across QGLWidgets

Posted by BitMaster on 06 August 2014 - 02:38 AM

I haven't tried it out myself but according to the documentation you can pass in the QGLContext to use in QGLWidget's constructor and when you create a QGLContext you can specify another context for sharing.

#5171570 How to use mkdir in java without knowing full path

Posted by BitMaster on 05 August 2014 - 01:54 AM

If the user installed the game it was most likely installed in the local equivalent of "Program Files", at least on Windows. You should not try to write there at all. If you need to store data, querying System.getProperty("user.home") would probably be the way to go.

If there is no conventional installation and/or you want the application to be portable you might want to query System.getProperty("user.dir") instead. However, my last adventure in Java has been a while so I'm not sure if there are better ways. I faintly remember having asked the root ClassLoader of the application of a similar question once but you would have to check with the documentation for details or whether that really makes sense.

#5170686 Understanding Qt At a Deeper Level

Posted by BitMaster on 31 July 2014 - 02:51 PM

In general I would advise not to actively use 'signals' or 'slots'. Since they are macros there is a risk for that to collide with third party libraries and to avoid problems here you can switch these macros off by configuring Qt accordingly. Instead, you should use 'Q_SIGNALS' and 'Q_SLOTS' which, while still macros, are not of such a risk of namespace collisions.


Also, for the purpose of understanding Qt at a deeper level I would forget about designing using .ui files. They don't allow you to do anything you could not also do by hand but they hide a lot of the details. That's good when you need to get something done quickly, it's bad when you really want to understand what is happening. Try building a few UIs yourself. Create layouts, add child widgets to them and research which signal/slot connections you need to get something done. That will be slow going at first but it will force you to do a lot of research in the documentation. Liberally read that, things linked there, as well as the introduction of Qt concepts.

#5170139 Setting up GLFW in Code::Blocks

Posted by BitMaster on 29 July 2014 - 12:30 PM

You need to link to OpenGL. The exact name will depend on your compiler but trying to add opengl32 will probably not be a bad idea. If you are already doing that, remember that the sequence of linked libraries is important for gcc.

#5169758 Make file unreadable by an external program

Posted by BitMaster on 28 July 2014 - 08:23 AM

I find it highly unlikely that Terraria encrypts its files. According to 30 seconds of Googling, it just appears to be a custom format, most likely to make loading and streaming easier. That's not encryption and any user with a bit of technical background can get access to the data even if the specification is not public for easier modding.

If you want to prevent casual opening/modifications of your resources give them a non-standard extension (like .myimage instead of .png). That should prevent opening them by simple double-click in Windows. Of course even a user with a minimum of technical understanding can still just drag the file into Gimp.
Alternatively just store multiple files inside some archive format. I would advise against encryption. It will most likely cause you more problems getting it right than a skilled user to grab the decryption keys from your own executable.

#5168856 This singleton keeps crashing.

Posted by BitMaster on 24 July 2014 - 06:32 AM

<stdint.h> is part of the C standard library, not the C++ standard library. While most compilers allow you to include their C includes from C++, they are not required to do so (nor do they even have to have C includes somewhere to be standard compliant).

#5166234 (Super) Smart Pointer

Posted by BitMaster on 11 July 2014 - 10:13 AM

shared_ptr doesn't seem to work because that is reference counted.

Or of course simply a weak_ptr.

#5165554 STL Map and SDL2 Texture segfault

Posted by BitMaster on 08 July 2014 - 09:12 AM

If something crashes deep inside the C++ standard library (although a lot of people call it carelessly the 'STL', it is not) you should walk up the stack trace and see what you are doing. Bugs in the standard library happen, but are not common at all. In practically all cases, the error is with you.

You posted a bit limited code (and no one knows how it looks now anyway), so here are two hints:
- if you add pointers to any local objects, you very likely should not do that
- if you add objects to the map, you need to make sure they respect the Rule of Three

#5165483 raw binary to obj conversion

Posted by BitMaster on 08 July 2014 - 02:19 AM

Have you evaluated GNU's Binary File Descriptor library referenced in the Wikipedia article?