c++

Is there a way to use macros to add additional values to an enum from elsewhere at compile time?

We use one big enum for message passing and there are optional parts of our code base that use specific messages that really only need to be added to the enum if those parts are to be compiled in. Is there a way to define a macro that could do this or something similar? I would like to be able to just add REGISTER_MSG(MESSAGE_NAME); to ...

C++ style menu bar in VB .Net?

Hello, Ive been looking a long time for this, but can't seem to find it. When I add a menu strip in vb .net, it looks like this: and I want it to look like the WinRar, Calculator, Notepad etc menus like this: From what I gathered, in vb 6 you could create a mainmenu and do it this way, but in vb .net it seems like all there is is...

How do I find resource leaks in Win32?

After running some hours my application fails in creating a new font object: CreateFontIndirect() returns NULL. I know how to find memory leaks (i.e. using parallel inspector or another profiler - most of them include leak detection). But how can i locate a ressource leak in Win32? ...

C++ DateTime class

I have my own C++ DateTime class defined as: class DateTime { public: int year; int month; int day; int hour; int min; int sec; int millisec; }; I have 2 DateTime which I need to compare to see which one is greater than (more recent) the other. Is there any freely available C++ DateTime class that I can use to Convert...

GTK Window configure events not propagating

I'm attempting to capture an event on a GTK window when the window is moved. I'm doing so with something that looks like this: void mycallback(GtkWindow* parentWindow, GdkEvent* event, gpointer data) { // do something... } ... GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_add_events(GTK_WIDGET(window), G...

Adding C++ custom action in Visual studio installer

hi, due to some constraints i want to write a custom action in c++ and add its assembly in Visual Sutdio installer... is it possible? as i know about c# or vb in those one can create classes inherited from Installer and it worked but now i want the same with C++.... ...

why message box is always hidden behind main dialog and cannot be shown on the top

I am using MFC to write a GUI application. I chose dialog-based application, and put picture control, edit box and buttons on it. When the picture control is mapped to the class derived from CWnd using DDX_Control, all the message boxes (including default system message box pop up when you enter invalid input in the edit box) are hidden...

Is this code O(N) or O(1)

vector<int>::iterator it; vector<int> p; p.push_back(4); p.push_back(5); p.push_back(6); p.push_back(7); it = p.begin() + 2; cout << it << endl; Is this O(N) or O(1)? And why? ...

finding why a DLL is being loaded

I have a winxp process which has all sorts of dlls and static libs. One of our libs is calling ms debug dlls, I have a suspicion which one it is but want to prove it in a tool like Process Explorer. How can I get a tree of my process, to see exactly who is loading what modules? ...

__declspec(dllimport/dllexport) and inheritance

Given a DLL with the following classes : #define DLLAPI __declspec(...) class DLLAPI Base { public: virtual void B(); }; class Derived : public Base { public: virtual void B(); virtual void D(); }; Will my "Derived" class be visible outside of the dll even if the "DLLAPI" keyword is not applied to the class defin...

Cast from size_t to int, or iterate with size_t?

Is it better to cast the iterator condition right operand from size_t to int, or iterate potentially past the maximum value of int? Is the answer implementation specific? int a; for (size_t i = 0; i < vect.size(); i++) { if (some_func((int)i)) { a = (int)i; } } int a; for (int i = 0; i < (int)vect.size(); i++) { ...

AfxGetAppName() returns garbage characters

I have the following line of code in my application: CString strAppName = AfxGetAppName(); Sometimes it fills strAppName up with garbage characters, and I can't figure out why. Anyone have any ideas? TIA. ...

Is there a library class to represent floating point numbers?

I am writing an application which does a lot of manipulation with decimal numbers (e.g. 57.65). As multiplications and divisions quickly erode their accuracy, I would like to store the numbers in a class which preserves their accuracy after manipulation, rather than rely on float and double. I am talking about something like this: clas...

MinGW compile for MS DOS

Hi all! I'm using Code::Blocks with MinGW to write my C++ applications in Windows XP. Now I want to compile my code to run under an MS DOS environment, so I can put it on my DOS formatted floppy disc. Can anyone help me? Thanks in advance. P.S. I don't mean the Command Prompt, but really the good old MS DOS Operating System. ...

Recommended book about parallel programming - theory & best practice?

I'm looking for a book or books about multicore, multithreaded programming. The perfect book should focus on best practices and maybe include a bit of theory background. I'm not interested in a book which only describes a single library and focuses on its API. OS actually doesn't matter. ...

Why does the library compiled on two slightly different machines behaves slightly different?

Here's the setup: My coworker has a Fedora x64_86 machine with a gcc 4.3.3 cross compiler (from buildroot). I have an Ubuntu 9.04 x64_86 machine with the same cross compiler. My coworker built an a library + test app that works on a test machine, I compiled the same library and testapp and it crashes on the same test machine. As far...

How to pass a C# Reference to COM Object to a C++ DLL

I am writing a Visual Studio add-in to process C++ code, and think that COM interop is slowing me down to much. I therefore want to pass a C# reference to a COM object to a small C++ DLL, have the DLL perform the necessary calculations and return back a string. I would be passing a CodeFunction2 object to the DLL and getting an XML str...

Why is the template argument deduction not working here?

Hello, I created two simple functions which get template parameters and an empty struct defining a type: //S<T>::type results in T& template <class T> struct S { typedef typename T& type; }; //Example 1: get one parameter by reference and return it by value template <class A> A temp(typename S<A>::type a1) { return a1; } //Exa...

BOOST_FOREACH: is there a trick to avoid the all-caps spelling ?

BOOST_FOREACH is really neat, but the C macro style of writing is somewhat off-putting. Is there a trick to avoid the all-caps spelling? ...

vs 2008 623 complier errors

I have a c++ console app that has been doing just fine and upon clean make started throwing compiler errors. Obviously I've redefined or omitted something, but I'm not sure what. ------ Rebuild All started: Project: alpineProbe, Configuration: Release Win32 ------ Deleting intermediate and output files for project 'abc', configuration ...