c++

Template instantiation with VARIANT return type.

An explicit instantiation of a static template member function keeps failing to compile with the message error C2785: 'at_Intermediate CUtil::convert_variant(const VARIANT &)' and '<Unknown>' have different return types When I make a corresponding class with non-static member functions, the compiler likes me. // utility class - stati...

Managed C++ wrappers for legacy C++ libraries

We're looking at writing a .Net-callable wrapper for some legacy C++ libraries using managed C++. It all looks pretty easy. Is there anything we need to watch out for? ...

Is it possible to manage C++ application via JMX ?

We have a distributed application containing C++ and Java modules, interacting via CORBA. Are there any C++ libraries/tools for exposing "variables" and "methods" to JMX tools (to create unigfied management) ? ...

How to prevent memory leaks while cancelling an operation in a worker thread C++?

Currently i am working on a desktop application which consists mathematical analysiss.I am using qt for GUI and project written in c++. When user starts an analysis, i open a worker thread and start a progress bar.Everything is ok up to now, problem starts when user cancels operation.Operation is complex, i am using several functions and...

Is Polymorphism worth an increase in coupling?

I'm writing a simplistic game to learn get some more C++ experience, and I have an idea where I feel polymorphism almost works, but doesn't. In this game, the Party moves fairly linearly through a Map, but can occasionally encounter a Fork in the road. A fork is (basically) an std::vector<location*>.Originally I was going to code somethi...

Convert CYMK image to RGB using BOOST::GIL

I am trying to use the boost generic image library to convert CYMK images to RGB. The following code does not compile // read cmyk image file cmyk8_image_t img; jpeg_read_image( "1502-T2-C-PER.jpg", img ); // convert to rgb rgb8_image_t rgb( img.dimensions() ); copy_pixels( color_converted_view<rgb8_image_t>(view(img)), view(rgb)); ...

Problem with OpenSSL library

Hello, I try to encrypt simple text with RSA algorithm. I have a problem with my code. RSA *_RSA ; unsigned char text[2560] = "A"; unsigned char sectext[2560]; unsigned char decrypttext[2560]; int i = 0; _RSA = RSA_generate_key ( 1024, 65537, NULL, NULL ); i = RSA_public_encrypt ( 1, text, sectext, _RSA, RSA_PKCS1_OAEP_PA...

Does this type of memory get allocated on the heap or the stack?

In the context of C++ (not that it matters): class Foo{ private: int x[100]; public: Foo(); } What I've learnt tells me that if you create an instance of Foo like so: Foo bar = new Foo(); Then the array x is allocated on the heap, but if you created an instance of Foo like so: Foo bar; Then it's created o...

Viewing include dependencies

Does anyone know of a tool that will analyse a C++ codebase and display a graphical representation of which files include which header files and highlight redundant includes? I've used Understand C++ but it's expensive and became very unwieldy very quickly on a large (and poorly encapsulated) codebase. ...

Can C++ template do this for conditions to improve code?

I want do this: func(conditionA ? pa1 : pa2, conditionB ? pb1 : pb2, conditionC ? pc1 : pc2); In C style function, there is no problem. But if func() is a template function, compiler will report errors. Here pa1 and pa2, ... are different class and have a static method - "convert()". convert() is also declared as inline for performance ...

Can you nest C preprocessor directives?

For instance, is the following possible: #define definer(x) #define #x? Thanks. ...

Why does std::auto_ptr operator = trash objects?

Seem to be having an issue with std::auto_ptr and assignment, such that the object referenced seems to get trashed for some reason. std::auto_ptr<AClass> someVar = new AClass(); // should work, but mangles content std::auto_ptr<AClass> someVar( new AClass() ); // works fine. std::auto_ptr<AClass> someVar = std::auto_ptr<AClass>(new ACl...

Access a COM Interface method C++

Both: CLSID IID Having specified the above, and using: CoCreateInstance() To returning a single uninitialised object of the class specified by the CLSID above. How can I then access an Interface's method from C++? Without: ATL MFC Just plain C++ Afterwards, I use CreateInstance() I'm having trouble, using CreateInstance() - wi...

Reading from 2 sockets in 2 threads causes data loss

I have a multi-threaded Windows C++ app written in Visual Studio 6. Within the app 2 threads are running each trying to read UDP packets on different ports. If I protect the reading from the socket with a critical section then all the date read is fine. Without that protection data is lost from both sockets. Is reading from a socket ...

Inspecting standard container (std::map) contents with gdb

Supposing to have something like this: #include <map> int main(){ std::map<int,int> m; m[1] = 2; m[2] = 4; return 0; } I would like to be able to inspect the contents of the map running the program from gdb. If I try using the subscript operator I get: (gdb) p m[1] Attempt to take address of value not located in mem...

Design of a polling event API

Say you were designing a C++ windowing library. It may or may not provide a callback API, but needs to provide a polling API to facilitate a functional style of programming. What would the polling API look like? Some options SDL style struct Event { enum { MousePress, KeyPress } type; union { struct { Point pos; Mouse...

How to use a program which is not in the source code's folder?

For example: I'm on MS DOS, I have a source code in the folder C:\Documents and Settings\Programs. Can i make my source code use a program (for example gnuplot) that is in a random folder? ...

Variable sized class - C++

I've seen a class which is a class which is defined like this.. class StringChild : public StringBase { public: //some non-virtual functions static StringChild* CreateMe(int size); private: unsigned char iBuf[1]; }; The static factory function has the following implementation.. return new(malloc(__builtin_offsetof...

C++ Library to Convert HTML to PDF?

Hello I am looking for a C/C++ library to convert HTML (Actually XHTML + CSS) documents to PDF. It is for commercial use and source would be nice but not essential. Anybody have any recommendations or experience doing this? UPDATE: To clarify, I am targeting the Windows platform only. I am developing with Borland C++ Builder 2006, bu...

Best QT ide?

What would be the best IDE to start programming with QT framework? IDE should support linux, windows and have a good mercurial integration. ...