c++

EnumPorts() returns strange error on some machines

I maintain an application that uses the win32 EnumPorts() function to help determine the set of serial ports installed on the computer. I have seen cases on some computers where the call to get this information fails with a GetLastError() code of 1722 (RPC server is unavailable). I assume that this has something to do with either regis...

In what cases do I use malloc vs new?

I am new to C++ programming but have a solid background in C#, Java and PHP. I see in C++ there are multiple ways to allocate and free data and I understand that when you call malloc you should call free and when you use the new operator you should pair with delete and it is a mistake to mix the two (eg. calling free() on something that...

Passing data between C++ (MFC) app and C#

We have a monolithic MFC GUI app that is nearing the end of it's life in C++. We are planning to build new functionality in C# and pass data between each app. Question is: What is the best approach for passing data between C++ and C#? Notes: Both ends will have a GUI front end and will probably only need to pass simple data like Id's ...

C++ testing framework: recommendation sought

I'm looking for a "quick and dirty" C++ testing framework I can use on my Windows/Visual Studio box. It's just me developing, so it doesn't have to be enterprise class software. Staring at a list of testing frameworks, I am somewhat befuddled... http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks#C.2B.2B ...

Crash when calling into C++ library from Perl using SWIG (AIX 5.1)

I'm trying to call into a C++ library from Perl on an AIX 5.1 machine. I've created a very simple test project to try to exercise this. My C++ shared library (test.cpp): #include <stdio.h> #include <iostream> void myfunc() { printf("in myfunc()\n"); std::cout << "in myfunc() also" << std::endl; } My SWIG interface file (tes...

Best way to design for localization of strings

This is kinda a general question, open for opinions. I've been trying to come up with a good way to design for localization of string resources for a Windows MFC application and related utilities. My wishlist is: Must preserve string literals in code (as opposed to replacing with macro #define resource ID's), so that the messages are s...

FileLoadException on windows 2003 for managed c++ dll

My company has login integration with GroupWise, and Exchange 5.5/2000+. The Exchange 5.5/GroupWise logic is done using wldap32.dll (win32), and so the login code is in a managed c++ class. When the configuration tool (or the backend service) tries to load the dll built off this managed c++ project on my XP development box, it works fi...

static variables in an inlined function

I have a function that is declared and defined in a header file. This is a problem all by itself. When that function is not inlined, every translation unit that uses that header gets a copy of the function, and when they are linked together there are duplicated. I "fixed" that by making the function inline, but I'm afraid that this is a ...

Initializing private static members

This feels like a dumb question, but what is the best way to initialize a private, static data member in C++? I tried this but it gives me weird linker errors: class foo { private: static int i; }; int foo::i = 0; I'm guessing this is because I can't initialize a private member from outside the class. So what's the best...

New project: I am having troubles picking a language to use.

I am starting my first independent for profit venture. I am having a hard time deciding what language to use. I want to write my app in Perl, but I don't think it will be simple enough to compile. If I don't write it in Perl I will write it in C++. The application will have many features, including wxwidgets interface, Deal with SDL, ti...

QT: difference between moc output in debug and release?

Using the QT Visual studio integration, adding a new QT class adds two separate moc.exe generated files - one for debug and one for release (and one for any other configuration currently existing). Yet the two eventual generated files seem to be identical. On the other hand when adding a UI class, the uic.exe generated files don't have ...

How do I listen/identify when a program runs in Windows using C++?

Specifically, I want to listen to when programs are run and record information such as: timestamp, executable, windows name and user. ...

What are some good DirectX resources for a beginner?

Hi all, I'm learning DirectX as part of a hobby project. I've been looking for some good online resources for DirectX9 (using C++, if that distinction matters), but haven't found anything that's a) great for a beginner and b) up to date. Any recommendations? ...

Exporting DLL C++ Class , question about .def file

I want to use implicit linking in my project , and nmake really wants a .def file . The problem is , that this is a class , and I don't know what to write in the exports section . Could anyone point me in the right direction ? The error message is the following : NMAKE : U1073: don't know how to make 'DLLCLASS.def' P.S: I'm trying to...

Program only crashes as release build -- how to debug?

I've got a "Schroedinger's Cat" type of problem here -- my program (actually the test suite for my program, but a program nonetheless) is crashing, but only when built in release mode, and only when launched from the command line. Through caveman debugging (ie, nasty printf() messages all over the place), I have determined the test meth...

if(str1==str2) versus if(str1.length()==str2.length() && str1==str2)

I've seen second one in another's code and I suppose this length comparison have been done to increase code productivity. It was used in a parser for a script language with a specific dictionary: words are 4 to 24 letters long with the average of 7-8 lettets, alphabet includes 26 latin letters plus "@","$" and "_". Length comparison we...

How to organize C++ test apps and related files?

I'm working on a C++ library that (among other stuff) has functions to read config files; and I want to add tests for this. So far, this has lead me to create lots of valid and invalid config files, each with only a few lines that test one specific functionality. But it has now got very unwieldy, as there are so many files, and also lots...

glBlendFunc and alpha blending

I want to know how the glBlendFunc works. For example, i have 2 gl textures, where the alpha is on tex1, i want to have alpha in my final image. Where the color is on tex1, i want the color from tex2 to be. ...

Virtual List Controls (MFC)

I am using a List Control to display a representation of elements within a vector. When the list is clicked on another control shows information about that element. The index of the element is currently determined by its index in the control, however if I wish to sort or filter the results this will no longer work. I have been told that...

How can I stop my MFC application from calling OnFileNew() when it starts?

I used Visual Studio's Application Wizard to create a skeleton MFC program with a multi-document interface. When I start this program, it automatically creates a child frame, which I don't want it to do - I need the main frame's client area to be empty until the user chooses to open a file. The debugger tells me that a CChildFrame obje...