Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 15 Aug 2010
Offline Last Active Jul 31 2013 10:30 AM

Topics I've Started

Poll: Does Gladwell's rule apply to game programming?

13 July 2013 - 02:59 AM

Feel free to elaborate your answer.

A difference between typedef and #define?

07 November 2011 - 09:10 AM


Can anyone come up with an example where you can not use this
typedef int MyIntType;
instead of this
#define MyIntType int
or vice versa for primitive data types?

Personally I would prefer a typedef since that would enable the compiler to report the correct type in case of an error, but I can actually not think of a situation where one style would have limitations compared to the other (unlike using #defines for constant values instead of declaring a const variable, for example).

EDIT: Oh yes, and besides the fact that typedefs are bound by namespaces, of course.

How much do you use your IDE?

17 August 2011 - 03:34 AM

Just curious :)

A peculiar problem ...

14 August 2011 - 03:21 PM


I have just encountered a rather non-trivial problem. First, look at this code:

char buffer[24];
This works beautifully! The string is copied nicely into the buffer as it is supposed to, and afterwards everything else continues smoothly.

Now, look at this code:

char buffer[24];
This is nothing less than a pure catastrophe! As soon as it is executed the program crashes, Windows pops up a message-box telling me that the program needs to close, and I am pretty sure that if it wasn't for Windows' Security Center it would erase my hard-drive as well.

The thing is that the first lines of code are executed in the main thread (the program) while the second ones are executed in a DLL procedure called by the main thread. Under different circumstances I would agree that two lines of code is not much to go on, but the essence of the problem can really be boiled down to why sprintf_s is causing the program to crash when invoked in a DLL procedure? (If you want to try it yourself first create a DLL file and export a function using sprintf_s. Then simply call the function from a test app to see the crash).

I have no idea what's causing this behavior so I am crossing my fingers one of you will be able to enlighten me.

PS1: I have also tried using std::stringstream/strings to solve the problem (converting a floating-point value to ASCII), but this solution crashed as well.
PS2: Floating-point support is loaded in both the program and in the DLL.

To goto or not to goto?

06 August 2011 - 03:04 PM

Well, the title says it all I guess :)