c++

Bullet Physics - Apply Torque Impulse in Body's Local Space

Hello, I'm currently evaluating the Bullet Physics Library for a 3D space game I'm writing using C++ and Ogre3D. I've gotten Ogre3D and Bullet integrated nicely by deriving from btMotionState and plugging in my SceneNodes, but now I'm having a lot of trouble calculating what values I should pass to btRigidBody::applyCentralImpulse and b...

Cross-Platform equivalent to windows events

I'm trying to port some Windows code to Linux, ideally through platform-independent libraries (eg boost), however I'm not sure how to port this bit of event code. The bit of code involves two threads (lets call them A and B). A wants to do something that only B can, so it sends B a message, then waits for B to say its done. In windows t...

sort using boost::bind

bool pred(int k, int l, int num1, int num2) { return (num1 < num2); } int main() { vector <int> nums; for (int i=50; i > 0; --i) { nums.push_back(i); } std::sort (nums.begin(), nums.end(), boost::bind(&pred, 5, 45)); } I am a boost newbie. I was learning to use boost::bind and I wanted to sort a vector of intege...

How can I tell that a directory is the Recycling bin in VB6?

I am attempting to port the code in this article to VB6, but I'm experiencing crashing. I'm pretty sure my error is in my call to SHBindToParent (MSDN entry) since SHParseDisplayName is returning 0 (S_OK) and ppidl is being set. I admit my mechanism of setting the riid (I used an equivalent type, a UUID) is pretty ugly, but I think it ...

Pruning a static library in c++

I am trying to expose a single well defined class by building a static library and then shipping the built library with a few header files that define that class and the interfaces needed to use it. I have that working but the problem I am running into is the library is gigantic. It has every single object file from the whole project and...

Getting back into Windows programming

I've been out of the Microsoft stack for a while now, been focused on Linux, open source stuff and web development in PHP. I used to do some desktop app development and some DirectX stuff on Windows in Dev Studio (all C and C++). I'd like to brush up on the MS stuff just to keep up on what's going on. I've installed MSVC++ 2008 Express ...

Crash in msvcp90d.dll when retrieving an iterator from a boost::tokenizer

When I retrieve the begin() iterator of a boost::tokenizer, I get a crash in msvcp90d.dll, that says "ITERATOR LIST CORRUPTED", which looks suspiciously like issues I have run into before with the _HAS_ITERATOR_DEBUGGING compiler flag, however I have verified that my program is being compiled with this flag turned off. Here is the prog...

Software Licensing: Do symbols/types apply?

I have some software that utilizes a C++ template library that is licensed MS-LPL. MS-LPL specifies:(F) Platform Limitation- The licenses granted in sections 2(A) & 2(B) extend only to the software or derivative works that you create that run on a Microsoft Windows operating system product. Which is my problem as I am moving this code ...

Class design ideas for state machine like object.

I'm writing a state machine like object. Looks like Class A: vector<Actions> m_enter_actions; vector<Actions> m_exit_actions; public: ClassA.... ~ClassA SetEnterActions(vector<Actions> vector) SetExitActions(vector<Actions> vector) Is this the best way to handle this? I wonder if I should have like Class A: EnterActio...

Using xml to load objects. Which is the best approach?

TinyXML I have a XML file that keeps a bunch of data that is loaded into objects. Right now, I have one giant method that parses the XML file and creates the appropriate objects depending on the contents of the XML file. This function is very large and imports lots of class definitions. Would it be better to each class type to do its ...

call matlab APIs in C C++

Hi, I just heard from somewhere that for numerical computation, "Matlab does offer some user-friendly APIs. If you call these APIs in your C/C++ code, you can speed up computation dramatically." But I did not find such information in Matlab documents like http://www.mathworks.com/support/tech-notes/1600/1622.html and http://www.mathwor...

C++ Object, Member's Memory Position Offset

Is there a better method to establish the positional offset of an object's data member than the following? class object { int a; char b; int c; }; object * o = new object(); int offset = (unsigned char *)&(object->c) - (unsigned char *)o; delete o; ...

Datastructure alignment.

So, I'm coding some packet structures (Ethernet, IP, etc) and noticed that some of them are followed by attribute((packed)) which prevents the gcc compiler from attempting to add padding to them. This makes sense, because these structures are supposed to go onto the wire. But then, I counted the words: struct ether_header { u_int8_t...

How to read a word into a string ignoring a certain character.

I am reading a text file which contains a word with a punctuation mark on it and I would like to read this word into a string without the punctuation marks. For example, a word may be " Hello, " I would like the string to get " Hello " (without the comma). How can I do that in C++ using ifstream libraries only. Can I use the ignore fu...

Erase-remove idiom: what happens when remove return past-the-end-iterator?

I got this question when I was reading erase-remove idiom (item 32) from Scott Meyers "Effective STL” book. vector<int> v; ... v.erase(remove(v.begin(), v.end(), 99), v.end()); remove basically returns the "new logical end” and elements of the original range that start at the "new logical end" of the range and continue until the real...

debugging a thread process using gdb/dbx

This might be genuine question but i am asking here since i was out of any clue when i was asked this question in an interview. how could we debug a thread which was created by another thread? let's say there is a main process and it calles the function pthread_create to create a thread process which is not joinable and that means both ...

difference between ++i and i++

Possible Duplicates: What is more efficient i++ or ++i? How do we explain the result of the expression (++x)+(++x)+(++x)? Difference between i++ and ++i in a loop? Hi I am trying these two programs void fun(){ int k=0; int i=10; k = (i++)+(++i); cout<<k<<endl; } Output = 22 as i++ will give 10 and ++i w...

Boundschecker does not terminate execution

I'm trying to generate a memory leak report using BoundsChecker 9.0.931.1 (BC.exe) through command line. The command I use is: BC.exe /B sessionlog.dbpcl /XD xmlout.xml /OUT errorfile.txt /S /NOLOGO /W D:\Test\debug__bin D:\Test\debug\bin\Application.exe "input.txt" I have instrumented the DLLs used by my application and the report can...

Boost spirit and forward declarations issues

Could someone please give me some advice/ideas about how to deal with the situations when it's needed to have a look at further declarations to be able to make correct semantic actions on current moment? For example, it is a well-known occurrence when someone writes an interpreter/compiler of some programming language which doesn't suppo...

Boost MinCut from MaxFlow

I need to get an st-MinCut of a graph. I recently started using the C++ Boost libraries, which don't seem to have that st-MinCut functionality, but the do have MaxFlow implementations and I can (in theory) make use of the MaxFlow/MinCut duality. I have gotten the "push relabel max flow" function working properly, but I can't figure out ...