c++

Differences between C++ and C#/.Net

If asked, how would you describe the differences between C++ and C#/.Net ...

Using mixed DLLs from /clr:pure projects

I'm building a project along with a Dll. The Dll must support native code so I declared it as a /clr. My project was initialy also a /clr project and everything was fine. However I'd like to include some NUnit testing so I had to switch my main project from /clr to /clr:pure. Everything still compiles but any Dll call generates a runti...

Project Explorer ,Mini buf expl Use in VIM

Any tricks for using project explorer in VIM? How can I search from all files in project? I tried \g \G but they dont work . How to toggle on off Project explorer window? I am using Project explorer and taglist and when I open both then there are two windows on left side ,this makes very much cluttered .Is it possible when to open tag...

Interview question about debugging, multithreading

Hi I had telephone interview question yesterday. The interviewer asked me if I had faced any challenging debugging issue? I told him I once faced a problem debugging someone else's code and it took me 3-4 days to solve that. I used Windbg, symbols and a crash dump to solve the problem. Now is this enough to tell? What is interviewer ex...

How to set a timeout on blocking sockets in boost asio?

Is there a way to cancel a pending operation (without disconnect) or set a timeout for the boost library functions? I.e. I want to set a timeout on blocking socket in boost asio? socket.read_some(boost::asio::buffer(pData, maxSize), error_); Example: I want to read some from the socket, but I want to throw an error if 10 seconds have ...

why is this legal, c++ typedef func

i did this in msvc 2005. typedef void (*cleanup_t)(); void func(cleanup_t clean) { cleanup_t(); } Why does this compile? and not give me a warning? ok, it gave me a unreferenced formal parameter warning but originally i did this when clean was in a class no there was no unreferenced formal parameter when this code gave me problem...

I'm interested in creating an OS. Where should I start?

I'm a handheld programmer (pocket pc mostly) I've been coding in C++ for 10 years. I'd like to build a PPC OS for the OLPC's XO, and I would like know where to get started. Does anyone have a good book I could use? ...

Outputting to stderr whenever malloc/free is called

With Linux/GCC/C++, I'd like to record something to stderr whenever malloc/free/new/delete are called. I'm trying to understand a library's memory allocations, and so I'd like to generate this output while I'm running unit tests. I use valgrind for mem leak detection, but I can't find an option to make it just log allocations. Any i...

Is there any reason not to make a member function virtual?

Is there any real reason not to make a member function virtual in C++? Of course, there's always the performance argument, but that doesn't seem to stick in most situations since the overhead of virtual functions is fairly low. On the other hand, I've been bitten a couple of times with forgetting to make a function virtual that should ...

Wrapping Visual C++ in C#

I need to do some process injection using C++ but I would prefer to use C# for everything other than the low level stuff. I have heard about "function wrapping" and "marshaling" and have done quite a bit of google searching and have found bits of information here and there but I am still really lacking. Things I have read in order of u...

Profiler for Visual Studio 2008, C++?

Are there any good, free (or at least reasonably cheap) profilers for at least native C++ that can integrate with Visual Studio 2008 Professional? I looked at DevPartner community edition but they seem to only support Visual Studio 2003 and Visual Studio 2005. Failing that are there any good free/cheap profilers in general that I c...

C++ reading from a file blocks any further writing. Why?

I am implementing a very simple file database. I have 2 basic operations: void Insert(const std::string & i_record) { //create or append to the file m_fileStream.open(m_fileName.c_str(), std::ios::out | std::ios::app); if (m_fileStream.is_open()) { m_fileStream << i_record << "\n"; } m_fileStream.flush(...

Cause of a memory leak in C++ when using the Boehm GC

This code is causing a memory leak for me, and I'm not sure why. [EDIT] Included code from here into question: #include "src/base.cpp" typedef std::map<std::string, AlObj*, std::less<std::string>, gc_allocator<std::pair<const std::string, AlObj*> > > KWARG_TYPE; AlInt::AlInt(int val) { this->value = val; this->setup(); }...

can you set SO_RCVTIMEO and SO_SNDTIMEO socket options in boost asio?

can you set SO_RCVTIMEO and SO_SNDTIMEO socket options in boost asio? If so how? Note I know you can use timers instead, but I'd like to know about these socket options in particular. ...

C++: Using operator of two intrinsic types as a function object

I have a vector-like class that contains an array of objects of type "T", and I want to implement 4 arithmetic operators, which will apply the operation on each item: // Constructors and other functions are omitted for brevity. template<class T, unsigned int D> class Vector { public: // Add a value to each item: naive implementatio...

What happens if you don't return a value in C++?

Yesterday, I found myself writing code like this: SomeStruct getSomeStruct() { SomeStruct input; cin >> input.x; cin >> input.y; } Of course forgetting to actually return the struct I just created. Oddly enough, the values in the struct that was returned by this function got initialized to zero (when compiled using g++ t...

Monitor process start in the system

Dear all, Is there a way to monitor processes starting in the system before they start? Example: On programs like ZoneAlarm or Antivirus programs, when you run a program it asks you if you allow running this program or not before it runs... Thanks so much, ...

Reading files larger than 4GB using c++ stl.

A few weeks back I was using std::ifstream to read in some files and it was failing immediately on open because the file was larger than 4GB. At the time I couldnt find a decent answer as to why it was limited to 32 bit files sizes, so I wrote my own using native OS API. So, my question then: Is there a way to handle files greater than ...

How could I create a custom windows message?

Our project is running on Windows CE 6.0 and is written in C++ . We have some problems with the code , and we are unable to debug . We also found out that if in our application we create threads and try to printf from them , the output won't appear . The only output that will appear is the one from the main thread . I would like to do th...

How could I know when someone attaches a removable disk on my computer?

I would like to know how can I detect when the user attaches a removable drive on a computer ( in a Windows XP environment ) . There surely has to be a better way than constantly checking to see if the number of drives increased , right ? ...