c++

Best practices for maitaining symbols of binaries

I have a product which has around 7 services and one User Interface. Time to time new releases are given in the product and hence the binaries get changed over a period of time. The customer base is huge and so we get queries related to crashes of our services in some cases. To identify the cause for crash we get the symbols(PDB) of the...

Initialize a reference - warning C4355: 'this' : used in base member initializer list

class A; class B { public: B(A& a) : a(a) {} private: A& a; }; /* Method 1 */ /* warning C4355: 'this' : used in base member initializer list */ /* class A { public: A() : b(*this) {} private: B b; }; */ /* Method 2 */ /* But I need to manually perform memory dellocation. */ class A { public: A() { b = new B(*this...

How to make object pointer NULL without setting it explicitly, without deleting explicitly and without static functions ?

Hi All, I am working on a c++ application. In my code i have an object pointer like TestClass *pObj = new TestClass(); and Member function call like pObj->close(); Inside close() member function, i should make pObj to NULL. As per our requirement, TestClass users should not call delete on pObj.(Destructor of TestClass is ...

EditStreamCallback with C#, Migrating from C++

I am trying to accomplish much the same thing as is being done here http://www.vbforums.com/showthread.php?t=449171 However using C#, instead of VB. What is snagging me the most is the C++ portion of the code. I have little to no experience with C++, and I have tried time and time again to make this '.dll' being spoken of, but it won't ...

Singleton dead reference problem

Hi, I was reading around a lot about singleton. I am thinking about the dead reference problem between singletons. In every primer on net , this problem is encountered when one singleton calls other singleton in its destructor, and that singleton is already destroyed, say Log singleton can be called from destructor of many other singlet...

Emacs C++, opening corresponding header file

I am new to emacs and I was wondering if there is a shortcut to switch between header/source and the corresponding source/header file if there is a reference card like the general emacs ref card Thanks ! ...

How to get mouse cursor icon VS c++

Hi, I use this code to get mouse position on screen and it's working. I also get cursor width and height. What I need is cursor icon in the moment I call function GetIconInfo. In ii iI have ii.hbmColor and ii.hbmMask. Value of hbmColor is 0x0, hbmMask is 0x2f0517f1. Can I extract mouse cursor from that two pointer and how? CURSORINFO ...

Calling LowLevelKeyboardProcedure in DLL

I've managed to get input hooks working, but now I'm kinda lost with putting them into a library. I have a simple header with INPUTHOOK_EXPORTS defined in the IDE, so the dll exports (Visual Studio). #pragma once #ifdef INPUTHOOK_EXPORTS #define INPUTHOOK_API __declspec(dllexport) #else #define INPUTHOOK_API __declspec(dllimpo...

Experience using Boost.Log logging library?

I am considering starting to use the Boost.Log logging library. Is anyone using Boost.Log? Please share your experiences in this regard. The other libraries I am considering are Apache log4cxx (it seems tedious to install but my team mates want something simple to get started) and Pantheios (the same problem since it works with extra fr...

How to avoid thread preemption in C++, VisualStudio(Windows)

Hi All, I developed a logger for testing our modules in c++, Win32 console, visual studio(Windows) Logger is running in one thread. While it displays output in console window, thread is getting preempted. Some other module thread is running. So output of other modules is getting mixed with output of Logger module in Console win...

A problem with Vivek's vcam of directshow

CVCam::CVCam(LPUNKNOWN lpunk, HRESULT *phr) : CSource(NAME("Virtual Cam"), lpunk, CLSID_VirtualCam) { ASSERT(phr); CAutoLock cAutoLock(&m_cStateLock); // Create the one and only output pin m_paStreams = (CSourceStream **) new CVCamStream*[1]; m_paStreams[0] = new CVCamStream(phr, this, L"Virtual Cam"); } What's...

Vectors within classes: handeling copy constructor and destructor (C++)

Take a simple class with the "big 3" (constructor, copy constructor, destructor): #include <vector> using namespace std; //actually goes in the C file that links to this header file ... class planets(){ //stores mass and radii data for planets in a solar system. public: vector <double> mass; vector <double> radius; //...

How to convert from LPCTSTR to LPSTR?

I have the following line of code: LPSTR address = T2A((LPTSTR)hostAddress); Can I convert LPCTSTR hostAddress to LPSTR without using T2A macros from "afxpriv.h"? ...

Class(Child window )destructor not getting called

I have created a window which has a toolbar with some icons, and I launch one more window clicking on the available icon from the main window. First window is created using CreateWindowEx method. the one I click using an icon is created using dialog resource. So without closing dialog, I directly close the main window. I see that dialog...

Is Visual C++ optimizer sensitive to amount of memory available?

Turns out it is perfectly valid for a C++ compiler to emit different machine code when recompiling the same program with exactly the same compiler/environment/whatever settings. Which implies that the compiler optimizer can decide how "deep" to optimize depending on various factors, amount of available memory included. Does anyone have ...

what is the persistent c++ system?

plz Send me the answer of the following question. what is the persistent c++ system? ...

Global variables not destructed in main thread?

I have a mixed-mode executable and I noticed that the constructor of my native global variables is called in the main thread, but the destructor is called in some other thread. The name of thread is 'Thread::intermediateThreadProc'. The global variables are What is the reason for this? And what is this 'Thread::intermediateThreadProc'...

Unexpected behaviour of getline() with ifstream

To simplify, I'm trying to read the content of a CSV-file using the ifstream class and its getline() member function. Here is this CSV-file: 1,2,3 4,5,6 And the code: #include <iostream> #include <typeinfo> #include <fstream> using namespace std; int main() { char csvLoc[] = "/the_CSV_file_localization/"; ifstream csvFile; ...

Can I pass STL data structures to a Win32 message loop?

I have a multithreaded Windows application where one of the threads has a message pump in it. I need to send a message to that thread, passing information to it. However, one of the libraries I want to use in the worker thread requires std::string. Can I do something like the following: typedef struct tagCOMMAND { std::map<std::stri...

Threading in Windows using C++

Hi, In C++ how can you use threads to not block my receive functionality in case of Sockets? // Receive until the peer closes the connection do { iResult = recv(lhSocket, recvbuf, recvbuflen, 0); if ( iResult > 0 ) printf("Bytes received: %d\n", iResult); else if ( iResult == 0 ) printf("Connection closed\n...