c++

Do STL maps initialize primitive types on insert?

I have a std::map like this: map<wstring,int> Scores; It stores names of players and scores. When someone gets a score I would simply do: Scores[wstrPlayerName]++; When there is no element in the map with the key wstrPlayerName it will create one, but does it initialize to zero or null before the increment or is it left undefined? ...

How can I convert a string to an integer in C++

I am trying to copy the value in bar into the integer foo. This is what I have so far. When I run it I get a different hex value. Any help would be great. int main() { string bar = "0x00EB0C62"; int foo = (int)bar; cout << hex << foo; ChangeMemVal("pinball.exe", (void*) foo, "100000", 4); return 0; } So the ou...

Problems linking static Intel IPP libraries on Linux with g++

I've been trying to move a project over from Xcode to Linux (Ubuntu x86 for now, but hopefully the statically-linked executable will run on an x86 CentOS machine? I hope I hope?). I have the whole project compiling but it fails at the linking stage-- it's giving me undefined references for all functions defined by IPP. This is probably...

Converting strings to enum in C++?

Strings to enum in C#, how do you normally converting strings to enum in C++. Any helper function that you use, is it a good idea to do this. ...

Create a new windows registry key using c++

Hello, I'm trying to create a new registry key in the windows registry using C++. Here is the code I have so far: HKEY hKey; LPCTSTR sk = TEXT("SOFTWARE\\OtherTestSoftware"); LONG openRes = RegCreateKeyEx( HKEY_LOCAL_MACHINE, sk, 0, NULL, REG_OPTION_BACKUP_RESTORE, KEY_ALL_ACCESS, NUL...

Having trouble initializing an SDL_Surface

I'm trying to set up something in SDL [in C++] where I can draw a one pixel big rectangle. I've got everything in my code working except my second SDL_Surface called rectangle. I'm having trouble initializing it. Here's the line where I try to initialize it: rectangle = SDL_Surface(SDL_DOUBLEBUF | SDL_HWACCEL | ...

Are missing invariants for an object always a sign of bad design?

I was just thinking of cases when invariant(s) for mainly classes, but to some extent also structs, cannot be readily defined. Would the lack of invariant(s) be a definitive sign of bad design of the class or struct, or can you see valid reasons not to be able to define them? To me, it feels like that's where you end up when things are ...

C++ 'true' and 'false' keywords suddenly not true or false in Visual C++ 6.0

My compiler (VC++ 6.0 sp6) has apparently gone insane. In certain pieces of code I'm seeing that 'bool mybool = true;' evalutes to and assigns false, and vice versa for true. Changing the true/false keywords to 1/0 makes it work fine. The same code compiles elsewhere fine without changing the true/false keywords. What could possibly ...

Transferring vector of objects between C++ DLL and Cpp/CLI console project

Hi, I have a C++ library app which talks to a C++ server and I am creating a vector of my custom class objects. But my Cpp/CLI console app(which interacts with native C++ ), throws a memory violation error when I try to return my custom class obj vector. Code Sample - In my native C++ class - std::vector<a> GetStuff(int x) { -- do...

CRecordset - get auto-generated ID after Update()

Having just called Update() on an MFC CRecordset (ODBC/Dynaset) what can I do to pull the auto-generated ID without hitting the database again? Ideally whatever it is would work in both SQL Server and MS Access (so querying for the last identity might not work...) ...

Scalable PPP protocol. Help Needed regarding State Machine

Hi, I am designing scalable PPP [mean it can be extended to over Ethernet, over HDLC, over ATM etc.]. I was stuck in determining whether State Machine is hadle by PPP stack [means i have design Base class for PPPStack in which FSM, encode, decode etc is there] or PPPoE [which is derived from my PPP Base Class PPPStack]. I am designing...

How to allow 32 bit apps on 64 bit windows to execute 64 bit apps provided in Windows\System32

Say you have an app, that you want to provide users ability to browse the system32 directory and execute programs in (like telnet). What is the best method for supporting this when you need to support XP onwards as a client and 2k onwards for server? Having written all this up I wonder if it's just too much time/effort in providing a b...

Unmanaged thread running Managed Code

I made a software that loads external module made by clients. This software is supposed to be HA (High availability) meaning it CAN'T be allowed to crash. For that purpose, I created a class which creates a thread, run the client module function in it, and returns. The class allows a certain time to execute the function, and if it take...

How to call a python function from a foreign language thread (C++)

Hi, I am developing a program that use DirectShow to grab audio data from media files. DirectShow use thread to pass audio data to the callback function in my program, and I let that callback function call another function in Python. I use Boost.Python to wrapper my library, the callback function : class PythonCallback { private: ...

g++ include all /usr/include recursively

I'm trying to compile a simple program, with #include <gtkmm.h> The path to gtkmm.h is /usr/include/gtkmm-2.4/gtkmm.h g++ doesn't see this file unless I specifically tell it -I /usr/include/gtkmm-2.4. My question is, how can I have g++ automatically look recursively through all the directories in /usr/include for all the header files...

How to implement RFC 3393 (Ipdv packet delay varation) in C?

Hello , I am building an Ethernet Application in which i will be sending packets from one side and receiving it on the other side. I want to calculate delay in packets at the receiver side as in RFC 3393. So I have to put a timestamps in the packet at the sender side and then take the timestamps at the receiver side as soon as i receive ...

How many threads to create and when?

I have a networking Linux application which receives RTP streams from multiple destinations, does very simple packet modification and then forwards the streams to the final destination. How do I decide how many threads I should have to process the data? I suppose, I cannot open a thread for each RTP stream as there could be thousands. S...

How to pass an interface pointer to a thread?

Note: Using raw Win32 CreateTheard() API No MFC An interface is simply a pointer to a vtable Question: How to pass an interface pointer to a thread? Illustration: IS8Simulation *pis8 = NULL; ... CoCreateInstance( clsid, NULL, CLSCTX_LOCAL_SERVER, __uuidof(IS8S...

How to determine if the current window is the active window?

How can I tell if my window is the current active window? My current guess is to do GetForegroundWindow and compare the HWND with that of my window. Is there a better method than that? I'm using Win32 API / MFC. ...

finding the caller of a constructor in C++

Looking for a quick and dirty way to identify the caller of a constructor (or any function for that matter) I am writing macros to help identify memory leaks by dumping the "this" pointers to OutputDebugString. Knowing where ctor and dtor was called from would help identify the problem. tnx \0 ...