c++

How do you detect/avoid Memory leaks in your (Unmanaged) code?

In unmanaged C/C++ code, what are the best practices to detect memory leaks? And coding guidelines to avoid? (As if it's that simple ;) We have used a bit of a silly way in the past: having a counter increment for every memory allocation call and decrement while freeing. At the end of the program, the counter value should be zero. I kn...

mmap() vs. reading blocks

I'm working on a program that will be processing files that could potentially be 100GB or more in size. The files contain sets of variable length records. I've got a first implementation up and running and am now looking towards improving performance, particularly at doing I/O more efficiently since the input file gets scanned many times...

Where's the Win32 resource for the mouse cursor for dragging splitters?

I am building a custom win32 control/widget and would like to change the cursor to a horizontal "splitter" symbol when hovering over a particular vertical line in the control. IE: I want to drag this vertical line (splitter bar) left and right (WEST and EAST). Of the the system cursors (OCR_*), the only cursor that makes sense is the OC...

Is there a way to parse a dependency tree from a build script output?

I have an inherited project that uses a build script (not make) to build and link the project with various libraries. When it performs a build I would like to parse the build output to determine what and where the actual static libraries being linked into the final executable are and where are they coming from. The script is compiling ...

Can UDP data be delivered corrupted?

Is it possible for UDP data to come to you corrupted? I know it is possible for it to be lost. ...

Why is Borland C++ better than Visual C++

Why is Borland C++ better than VC++? ...

Is it possible to develop DirectX apps in Linux?

More out of interest than anything else, but can you compile a DirectX app under linux? Obviously there's no official SDK, but I was thinking it might be possible with wine. Presumably wine has an implementation of the DirectX interface in order to run games? Is it possible to link against that? (edit: This is called winelib) Failing ...

Deciphering C++ template error messages

I'm really beginning to understand what people mean when they say that C++'s error messages are pretty terrible in regards to templates. I've seen horrendously long errors for things as simple as a function not matching its prototype. Are there any tricks to deciphering these errors? EDIT: I'm using both gcc and MSVC. They both seem...

How do you set, clear and toggle a single bit in C?

How to set, clear and toggle a bit in C? ...

What is a jump table?

Can someone explain the mechanics of a jump table and why is would be needed in embedded systems? ...

Is there an alternative to using % (modulus) in C/C++?

I read somewhere once that the modulus operator is inefficient on small embedded devices such as 8 bit micros without integer division operator. Perhaps someone can confirm this but I thought the difference is 5-10 time slower than with an integer division operation. Is there another way to do this other than keeping a counter variable ...

C++ deleting a pointer to a pointer

So I have a pointer to an array of pointers. If I delete it like this: delete [] PointerToPointers; Will that delete all the pointed to pointers as well? If not, do I have to loop over all of the pointers and delete them as well, or is there an easier way to do it? My google-fu doesn't seem to give me any good answers to this quest...

C++ UI resources.

Now that I know C++ i want to get into desktop application that have a UI instead of Command Prompt stuff, where should I start, and what are some good online resources? ...

C++ Practice Problems

I am learning C++ currently and am probably at the intermediate level. I am running out of ideas for what to do with my current programming skill. And, as the title puts it I need some practice problems. ps. maybe the problems can be divided into beginner, intermediate and advanced ...

Am I allowed to run a javascript runtime (like v8) on the iPhone?

According to this discussion, the iphone agreement says that it doesn't allow "loading of plugins or running interpreted code that has been downloaded". Technically, I would like to download scripts from our server (embedded in a proprietary protocol). Does this mean I wouldn't be allowed to run a runtime like v8 in an iphone app? Thi...

Eclipse spelling engine does not exist

I'm using Eclipse 3.4 (Ganymede) with CDT 5 on Windows. When the integrated spell checker doesn't know some word, it proposes (among others) the option to add the word to a user dictionary. If the user dictionary doesn't exist yet, the spell checker offers then to help configuring it and shows the "General/Editors/Text Editors/Spelling...

What's the best tool to graphically display memory layout from a .map file?

My build (gcc) toolchain produces a .map file. Is there a tool to analyze the memory map graphically? ...

How to teach a crash course on C++?

In a few weeks we'll be teaching a crash course on C++ for Java programmers straight out of college. They have little or no experience yet with C or C++. Previous editions of this course were just 1 or 2 half-day sessions and covered topics including: new language features, e.g. header vs. implementation pointers and references memor...

Does ScopeGuard use really lead to better code?

I came across this article written by Andrei Alexandrescu and Petru Marginean many years ago, which presents and discusses a utility class called ScopeGuard for writing exception-safe code. I'd like to know if coding with these objects truly leads to better code or if it obfuscates error handling, in that perhaps the guard's callback wou...

What does the const operator mean when used with a method in C++?

Given a declaration like this: class A { public void Foo() const; }; What does it mean? Google turns up this: Member functions should be declared with the const keyword after them if they can operate on a const (this) object. If the function is not declared const, in can not be applied to a const object, and the compiler will...