c++

Is it possible to share an enum declaration between C# and unmanaged C++?

Is there a way to share an enum definition between native (unmanaged) C++ and (managed) C#? I have the following enum used in completely unmanaged code: enum MyEnum { myVal1, myVal2 }; Our application sometimes uses a managed component. That C# component gets the enum item values as ints via a managed C++ interop dll (from the nativ...

Templated Barton and Nackman Trick Problems

I'm trying to implement class using the Barton and Nackman trick to avoid dynamic dispatch. (I'm writing MCMC code where performance matters.) I'm not a C++ expert but the basic trick is working for me elsewhere. However I now have a case where the second derived class needs to be templated. This seems to cause problems. The outline ...

Preventing Resource DLLs from being hacked

I develop in C++/MFC and have placed all the resources in a separate DLL. I have seen cases where the resource DLL is modified and the product is sold illegally with different name, graphics etc. How do I prevent the resource DLL from being modified/hacked? ...

How to pass a function pointer that points to constructor?

I'm working on implementing a reflection mechanism in C++. All objects within my code are a subclass of Object(my own generic type) that contain a static member datum of type Class. class Class{ public: Class(const std::string &n, Object *(*c)()); protected: std::string name; // Name for subclass Object *(*create)(); // Po...

I want to learn COM. How should I proceed?

Hello Guys, I am a fresh graduate with a bachelor in Computer Science. As most school today, they are no longer teaching students C or advance C++ (only an Introductory course in C++... With lessons up to Pointers). The standard programming language prescribed in the curriculum is C# (.NET stack). Just recently, I got hired as a junior...

Can smart pointers selectively hide or re-direct function calls to the objects they are wrapping?

I'm working on a project where certain objects are referenced counted -- it's a very similar setup to COM. Anyway, our project does have smart pointers that alleviate the need to explicitly call Add() and Release() for these objects. The problem is that sometimes, developers are still calling Release() with the smart pointer. What I'm...

Large number of simulteneous connections in thrift.

Hello, I'm trying to write a simple server with Thrift. At the beginning it looked promising, but I've stumbled into a problem with a number of clients connected at the same time. I'm using TThreadPoolServer, which allows 4 client to connect and then blocks other clients until I kill one from the connected. What can I do to allow more (p...

Cant focus WxWidgets frame in Mac OSX compiled with SCons

Hello. I have this WxWidgets test source code that compiles, and when run, it shows a simple frame: /* * hworld.cpp * Hello world sample by Robert Roebling */ #include "wx-2.8/wx/wx.h" class MyApp: public wxApp { virtual bool OnInit(); }; class MyFrame: public wxFrame { public: MyFrame(const wxString& title, const wxPoin...

missing ; before identifier while compiling VC6 code in VC9

The following code compiles fine in VC6 but when I compile the same project in VS2008 it gives the following error error C2146: syntax error : missing ';' before identifier 'm_pItr' template <class pKey, class Data, class pCompare, class hKey = int, class hCompare = less<hKey>, class sKey = int, class sCompare = less<sKey...

How to get Apply button to show in property sheets in Windows Mobile 5 / PocketPC

I have an C++ MFC applications that runs on most flavours of Windows CE / Mobile / PocketPC and Win32. When using CPropertySheet based tabbed dialogs the application under Win32, I get Ok,Cancel, Apply & Help buttons on the bottom of the dialog. On Windows CE, I get ?, OK and X buttons on the top of the dialog which do pretty much the ...

Prepare public header for release

Hi! I'm interested in hearing what routines you have for cleaning up public header files you distribute to customers. Some things I'd like to hear your opinions on are: Comments not meant for external consumption. Generally I like keeping documentation close to the code and comments like this might not be a good idea to share: /** *...

How to use CLR in a different runtime environments under multiple projects in visualstudio??

Hi Here is My Scenario. I have an Existing Solution in visualstudio which contains 15 projects. in some project i need to use managed c++ extensions. So first i have a workaround for sample solution contains 4 projects in those i have maintained dependencies b/w them. and my solution is builded also. I apply the same procedure to ex...

Interfacing MFC and Command Line

I'd like to add a command line interface to my MFC application so that I could provide command line parameters. These parameters would configure how the application started. However, I can't figure out how to interface these two. How could I go about doing this, if it's even possible? ...

problem of gzip compression in symbian c++

Compress(TInt aCompressionMethod,const TDesC8 data) { TInt compressionMethod = 0; if(aCompressionMethod == 0) compressionMethod = Z_DEFAULT_COMPRESSION; iCompressor =CEZCompressor::NewLC(*this,Z_DEFAULT_COMPRESSION); TRAPD(err, iCompressor->CompressL(cipher,text)); } i am using compression using gzip method in symbian in ...

specialised hash table c++

I need to count a lot of different items. I'm processing a list of pairs such as: A34223,34 B23423,-23 23423212,16 What I was planning to do was hash the first value (the key) into a 32bit integer which will then be a key to a sparse structure where the 'value' will be added (all start at zero) number and be negative. Given that they...

Best java book for a c++ developer?

Thinking in Java third edition is the one, for which I have a eBook with me.My primary focus is to take advantage of google frameworks like Android and GWT. ...

Using C++ Library in Linux (eclipse)

Hello everyone! I wrote a library and want to test it. I wrote the following program, but I get an error message from eclipse. #include <stdlib.h> #include <stdio.h> #include <dlfcn.h> int main(int argc, char **argv) { void *handle; double (*desk)(char*); char *error; handle = dlopen ("/lib/CEDD_LIB.so.6", RTLD_LAZY);...

eliminating the inter-compiler incompatibility issue with C++ dynamic libraries

..., a follow up to this. From the answers I've been given to my referenced question I've learned that: different compilers use different name decoration, which makes it impossible to use a C++ dynamic library built with compiler A in a project built with compiler B, the library can be built as static saving me including n header and ...

Remove ribbon bar in MFC c++

Hello, I'm trying to remove the ribbon bar, but let stay the quick access tool bar and the icon orb, can anyone tell me if this is possible? and if yes how i can do this? I try to hide it by calling the RemoveAllCategories function and then minimizing the ribbon, the problem is that the bar that holds the categories tabs stays visible ...

What are your recomendations for a C++ interface to Prolog?

I'm interested in using Prolog in a C++ program I'm developing. I've come across the SWI-Prolog interface for C++, but I wanted to ask the SO crowd what your personal experience and reccomendation would be before I get serious about developing my application. The reason I'm looking into this is in order to embed a relatively simple and...