c++

How to make MSVC debug builds run faster

We have a large C++ application, which sometimes we need to run as a debug build in order to investigate bugs. The debug build is much much slower than the release build, to the point of being almost unusable. What tricks are available for making MSVC Debug builds execute faster without sacrificing too much on the debugability? ...

How do I return a string array in c# and use it in unmanaged c++?

Can any one tell me how to return a String array from a method and use it in c#? Suppose i have to return an array of {one,two, .....ten} and in c++ i have to display this array on console and perform some actions. ...

how do i write an overload operator>> function of class string?

class string { public: friend istream& operator >> ( istream& is, string& str); private: char *m_data; }; int main() { string str; freopen("in.txt","r",stdin); while( cin >> str) { cout < < str < < endl; } return 0; } the content of in.txt are: asdfsfgfdgdfg in the overload func...

Run pdflatex quietly

I'm calling pdflatex from within my (C++) program using system(), needless to say all the garbage pdflatex puts on screen is a bit irritating in this case. So...how do I encourage pdflatex to forego the lengthy outputs? It would be even better if only errors would be visible... ...

Retrieving DLL name, not calling application name

I've written two COM classes in C++, contained in a single MFC DLL. They're being loaded as plugins by a 3rd party application. How can I get the file name, and version number, of the DLL from within those classes? ...

compilation error while #import tlb file in COM automation

Hi, I am trying to #include an application tlb file in VC++ project. Getting following compilation errors, after #import "CANoe.tlb" in my project source file. - unknown character '0x1' syntax error : missing ';' before identifier 'A' missing type specifier int assumed. Note: C++ does not support default-int '{' : missing functio...

php c++ communication

hi i am new in php,i made the whole code in c++ and want to use this code in php.so i made dll to my code for using it.but i am not able to use this dll in php ,can anybody send me the complete code to use php,c++ extensions. ...

How to make data ownership explicit in C++

When working with pointers and references in C++, it is sometimes difficult to see whether the pointer has ownership over the referenced data, or if it is just a temporal reference. For example: Instance* i = new Instance(); Instance* j = i; How can it be made clear which of the 2 pointers has ownership over the instance? In other wor...

c++ exceptions, can what() be NULL?

Can a caught std::exception ever have what() being NULL? Is the checking for e.what() below overhead? //... } catch (const std::exception& e) { std::string error; if(e.what()) error = e.what(); } ...

Are different compilers' C++ virtual inheritance implementations incompatible?

I have hierarchy of public interfaces like this: struct ISwitchable { /* Obtain pointer to another implemented interface of the same instance. */ virtual int switch(unsigned int interfaceId, void** pInstance) = 0; }; struct IFoo : public ISwitchable { /* Methods */ }; struct IBar : public ISwitchable { /* Methods */ }; struct ...

Erase/Remove contents from the map (or any other STL container) while iterating it

Allegedly you cannot just erase/remove an element in a container while iterating as iterator becomes invalid. What are the (safe) ways to remove the elements that meet a certain condition? please only stl, no boost or tr1. Thanks EDIT Is there a more elegant way if I want to erase a number of elements that meet a certain criteria, perh...

How should I use a QGraphicsScene with layouts and widgets

I'm creating some graphic data displaying widget in Qt4 and I was tempted to use the QGraphicsScene for it, create QGraphicsItems for the data items etc. However, I wanted to add some layer of controls (eg. scrollbars, zoom+other buttons - I want to make it in a similar style as eg. Google Maps, that is, the data would be displayed all ...

How can I decrypt a file encrypted in Perl using Crypt::CBC (Blowfish) in C?

I have a small encryption tool in Perl which uses the Crypt::CBC and Blowfish to encrypt files. I want to write the decryption algorithm in C or C++ ... Please somebody help me in doing this. ...

Why is the beginning of my string disappearing?

In the following C++ code, I realised that gcount() was returning a larger number than I wanted, because getline() consumes the final newline character but doesn't send it to the input stream. What I still don't understand is the program's output, though. For input "Test\n", why do I get " est\n"? How come my mistake affects the first...

Why does std::fstream set the EOF bit the way it does?

I recently ran into a problem caused by using fstream::eof(). I read the following line from here: The function eof() returns true if the end of the associated input file has been reached, false otherwise. and (mistakenly) assumed this meant that if I used fstream::read() and read past the end of the file, the function eof() would...

Disabling Vista-Style controls in Application

So I'm trying to recompile an application to add some minor features. All is well, except for one thing. The old version has all the windows-vista-style dialog buttons. The corners are rounded, the radio buttons look different, etc. Example How do I turn those things on? I want it to look/feel like the original. EDIT: If anyo...

ISAPI Extensions: What is the difference between TerminateExtension and the extensions destructor?

Is there a difference between TerminateExtension() and the extensions destructor? Obviously both are used to cleanup resources but what kind of cleanup should be in one function and not the other? ...

Building .NET COMInterop project without first registering the COM service

I am building a C# UI to interact with a COM Service (.exe). The VS2005 COM project outputs a valid typelib (TLB), which is referenced by the C# project. However, the VS2005 C# project insists that the service be registered in order to build the C# project, even though the typelib appears perfectly valid when examined with the OLE Obje...

Why is the C++ STL is so heavily based on templates? (and not on *interfaces*)

I mean, aside from its obligating name (the Standard Template Library)... C++ initially intended to present OOP concepts into C. That is: you could tell what a specific entity could and couldn't do (regardless of how it does it) based on its class and class hierarchy. Some compositions of abilities are more difficult to describe in this...

Boost Thread Cancelling

Can you cancel a Boost Thread as you would a pthread? I'm writing a simple watchdog to terminate worker threads if they crash and there doesn't seem to be a way to simply cancel a thread in the Boost Thread library. ...