c++

Can someone help spot the errors in my low lock list?

Hi all, I've written a low lock list in C++ on windows 32-bit. I'm getting BIG improvements over using critical sections but I'd like someone to sanity check that what I'm doing is correct and there aren't any errors in what I've done: #ifndef __LOW_LOCK_STACK_H_ #define __LOW_LOCK_STACK_H_ template< class T > class LowLockStack { pr...

global vector C++

Is it possible to have a vector as a global variable is C++? Like this: class system {...}; vector<system> systems; when I try to compile this I get an error. The compiler I'm using is gcc and I'm compiling as C++. ...

read in data file from MATLAB to Dev C++

Here's what I want to do: Take 2x101 matrix for x and y coordinates and import that data in Dev C++ in program and use it for that code. Right now my Dev code has double Cord[NCargo][2] = {{x0,y0},{x1,y2},{...},{x100,y100}} You get the idea. I want my .mat file matrix read into and put into this Cord Matrix. The name of my C+...

Inheritance mucking up polymorphism in C++?

Perhaps my knowledge of inheritance and polymorphism isn't what I thought it was. Can anyone shed some light? Setup (trivialization of problem): class X { }; class Y { }; class Base { public: void f( X* ) {} }; class Child: public Base { public: void f( Y* ) {} }; Question: This should work, right? int main( void ) {...

Avoid making copies with vectors of vectors

I want to be able to have a vector of vectors of some type such as: vector<vector<MyStruct> > vecOfVec; I then create a vector of MyStruct, and populate it. vector<MyStruct> someStructs; // Populate it with data Then finally add someStructs to vecOfVec; vecOfVec.push_back(someStructs); What I want to do is avoid having the copy ...

What's the intended use of _fread_nolock, _fseek_nolock?

Hi there, we have a C++ class which basically reads and writes vectors from a binary file. An exemplary read function that loads a single vector into memory looks like this: int load (const __int64 index, T* values) const { int re = _fseeki64(_file, index * _vectorSize + _offsetData, SEEK_SET); assert(re == 0); size_t read = frea...

how to hook control closing in an MFC custom control class

I am interested in allocating pointers, storing those in the LPARAM data of a comboboxex control, and making that control responsible for deleting those pointers when it is destroyed. Since I am working in MFC, I can subclass a CComboBoxEx, and add either a message handler or a virtual member function. The question is: Is this pattern ...

How can I obfuscate a test in code to prevent tampering with response processing?

I am looking for a way to obfuscate (in the object code) a test - something like what might be done to check that a license key is valid. What I am trying to prevent is someone searching through an image binary for the code that processes the response. bool checkError = foo(); if ( checkError ) // I'd like to avoid making a simple check...

the procedure entry point ?_Xmem@tr1@std@@YAXXZ could not be located in the dynamic link library MSVCP90D.dll

Hi All, I have installed VS2008 FeaturePack so as to work with regular expressions in C++. However when I execute the program i get the following error. the procedure entry point ?_Xmem@tr1@std@@YAXXZ could not be located in the dynamic link library MSVCP90D.dll. How could have gone wrong? Thanks and Regards, SS ...

Why is it #elif and not #elsif in C/C++

Is there a particular reason when C / C++ were created that #elif was chosen over #elsif? if ( ) { } else if ( ) { } else { } Fixed syntax ...

Add the upper and lower 64-bits of a 128-bit xmm register

I have two packed quadword integers in xmm0 and I need to add them together and store the result in a memory location. I can guarantee that the value of the each integer is less than 2^15. Right now, I'm doing the following: int temp; .... movdq2q mm0, xmm0 psrldq xmm0, 8 movdq2q mm1, xmm0 paddq mm0,mm1 movd temp, mm0...

InPlaceActivate on ATL control not called until mouse event

I have an ActiveX control written in C++ that I created with VS2008 and ATL. For the most part, it is a pretty standard (not modified much from the original template) control, except that instead of using IDispatchImpl, I have created my own IDispatchEx implementation. This control is only used in Internet Explorer, and I have been tes...

C++ internal code reuse: compile everything or share the library / dynamic library?

General question: For unmanaged C++, what's better for internal code sharing? Reuse code by sharing the actual source code? OR Reuse code by sharing the library / dynamic library (+ all the header files) Whichever it is: what's your strategy for reducing duplicate code (copy-paste syndrome), code bloat? Specific example: Here's ...

Sending a struct from C++ to WPF using WM_COPYDATA

I have a native C++ application that, for the time being simply needs to send its command line string and current mouse cursor coordinates to a WPF application. The message is sent and received just fine, but I cannot convert the IntPtr instance in C# to a struct. When I try to do so, the application will either crash without exception ...

g++ linker error: Getting undefined reference error for std::hash

Hi, I'm using the unordered_map of TR1 implementation in my code and the linker gives weird errors I cannot even decipher: BPCFG.o: In function `std::__detail::_Hash_code_base<DottedRule, std::pair<DottedRule const, int>, std::_Select1st<std::pair<DottedRule const, int> >, eqDottedRule, std::hash<DottedRule>, std::__detail::_Mod_rang...

What's a pattern for getting two "deep" parts of a multi-threaded program talking to each other?

I have this general problem in design, refactoring or "triage": I have an existing multi-threaded C++ application which searches for data using a number of plugin libraries. With the current search interface, a given plugin receives a search string and a pointer to a QList object. Running on a different thread, the plugin goes out and s...

high speed interprocess associative array

Is there library usable from c++ for sharing fairly simple data (integers,floating point numbers, strings) between cooperative processes? Must be : high-speed (SQL-based methods too slow due to parsing) able to get,set,update,delete both fixed and variable data types (e.g. int and string) ACID (atomic,consistent,isolated,durable) us...

Detect VMWare programatically

I would like to check if my application is being run on VMWare. Is there a reliable way to do this in C++? ...

How can I control my L-System pattern with my code?

I am working on a project to display and animate a tree growing. I am using C++ and OpenGL on this project. The tree grows to a certain number of branches, stops, and then the tree's leaves fall to the ground. I have decided to use Lidenmayer systems to graphically depict this because it seemed an easier alternative to creating a structu...

Is there a way to embed windows save dialog

The subject has it all. I want to have the Windows save as dialog as part of my own dialog. Is that even possible ? ...