Jump to content

  • Log In with Google      Sign In   
  • Create Account


SiCrane

Member Since 09 Dec 1999
Offline Last Active Private
*****

#4919652 COM as a way to implement the use of STL containers across a DLL

Posted by SiCrane on 05 March 2012 - 08:15 PM

As long as the implementation is completely hidden and the interface contains only legal types, then it shouldn't be a problem.


#4919597 Why can't static const float members be initialized in a class?

Posted by SiCrane on 05 March 2012 - 04:17 PM

It is the correct explanation.

Source?


#4919446 Why can't static const float members be initialized in a class?

Posted by SiCrane on 05 March 2012 - 08:13 AM

It's also an incorrect explanation. If that was the reason, then compilers like gcc wouldn't have been able to offer static const float member variables with inline definitions as extensions. And changing a variable defined as const isn't legal even if they have storage. There's nothing inherent to floating point numbers that requires them to be initialized at runtime otherwise constexpr wouldn't work with floats.


#4919224 Why can't static const float members be initialized in a class?

Posted by SiCrane on 04 March 2012 - 12:18 PM

Nice way to take posts out of context. This is the post those were the response to:

Is it because float is old-school..
Because i can use

static const long color = ... //Works like a charm.

The long type works because it's an integral type and float doesn't because it's not a integral or enumeration type. And if you were actually paying attention to the thread rather than locking in on random details to nitpick you'd notice that the C++11 standard does currently allow for inline literal type initialization, so there currently is no technical limitation.

However, since you seem to have all the answers here, why didn't you give the reasons? Or do you just like lecturing from a position of ignorance?


#4919198 Why would this fail?

Posted by SiCrane on 04 March 2012 - 10:37 AM

Depending on your compiler, it may have heap debugging facilities. For example, the code sanchopan posted is MSVC specific. On Windows you can also use Application Verifier to debug some kinds of heap usage errors such as buffer overruns.


#4919193 Why can't static const float members be initialized in a class?

Posted by SiCrane on 04 March 2012 - 10:28 AM

Or upgrade to C++11 and use constexpr.


#4918769 Run-Time Check Failure #0 Fun Stadium

Posted by SiCrane on 02 March 2012 - 07:59 PM

In this case you can use a dynamic_cast to get from one interface to the other. A C style cast will just reinterpret the address as the other interface, but with multiple interfaces the interfaces have different addresses for the same object.


#4917740 Explain this set of Code

Posted by SiCrane on 29 February 2012 - 07:54 AM

I've always wondered whether there was a practical application for the flexibility of this rule, beyond the literal 0 value...

This is the explanation I've heard: programmers frequently misuse the NULL macro, such as assigning it to integers. Sometimes some issues can be detected by using a null pointer constant other than 0. For example, if pointers are 64-bit and ints are 32-bit, assigning 0 to an int won't give you warning that an int doesn't have enough bits to represent an actual full pointer. On the other hand, if long long could hold that value you can #define NULL ((long long)0) which would still be a legal null pointer constant but would also tell you that your destination size is too small if you tried assigning to a regular int.


#4917596 Python or C#?

Posted by SiCrane on 28 February 2012 - 08:43 PM

While I like Python, I find that the mainstream game development libraries for C# tend to be of higher quality with better documentation, etc. So between the two, for game development, I'd recommend C#. But honestly, sticking with Python for a while won't hurt you in the long run either.


#4917431 Calling externally defined funcs from DLL?

Posted by SiCrane on 28 February 2012 - 11:08 AM

You can also just pass a function pointer to the DLL as an initialization step.


#4917395 Why does this syntax compile on gcc?

Posted by SiCrane on 28 February 2012 - 08:58 AM

This is a GCC extension.


#4917173 simple c# question

Posted by SiCrane on 27 February 2012 - 03:55 PM

Did you try Enum.GetName()?


#4916832 Integers

Posted by SiCrane on 26 February 2012 - 04:32 PM

For the record, what the standard claims about the size of integers goes like this: sizeof(signed char) = 1 <= sizeof(short) <= sizeof(int) <= sizeof(long) <= sizeof(long long). char is at least 8 bits, short and int are both at least 16 bits, long is at least 32 bits and long long is at least 64 bits.

I've personally used compilers with 16 bit ints back in DOS days, and at least one embedded system out there (predating long long) made everything 32 bits, and it was perfectly conforming.


#4916830 More AngelScript binding wrappers

Posted by SiCrane on 26 February 2012 - 04:23 PM

The functions returned by WRAP_MFN() are generic calling conventions so should be registered with asCALL_GENERIC. Since it looks like you're using native calling conventions, then you don't need to use WRAP_MFN(), etc. Just use asMETHOD and asCALL_THISCALL. You would use these if you want to create generic calling convention wrappers for native functions. For example, if your platform doesn't support native calls.


#4916585 How far do you go to encapsulate?

Posted by SiCrane on 25 February 2012 - 04:02 PM

Implementation details, like degree of encapsulation, depend not only what a class does, but also on why it exists. Why does your WidgetCollection exist? What problem is it intended to solve?




PARTNERS