Welcome to the Wolfire Blog! This is where we keep everyone up to date on our progress on Overgrowth and other new stuff. Be sure to subscribe to get the latest news! Also, be sure to check out the forums for even more up to date news - or get on IRC for up to the second updates.

Obscure Visual C++ features

Add Comment! By David Rosen on March 14th, 2010

A couple days ago I wrote about solutions to some common Visual C++ problems (click here to read it). Today I would like to share some obscure features of VC++ that are actually very useful.

Local optimization flags

When writing computer programs, it's common to have two build targets: one with full optimization and one with no optimization. The full optimization runs much more efficiently, but is very hard to debug. The one with no optimization is easy to debug, but runs very slowly. But what if you need it to run efficiently and also be easy to debug? That's where local optimization flags come in. These allow you to disable optimizations for a certain block of code while the rest of the program runs at full speed. To do this, just surround the code you're debugging with #pragma optimize("", off) and #pragma optimize("", on), like this:

#pragma optimize("", off)

void FunctionToDebug() {

#pragma optimize("", on)

Keyboard shortcuts

There are so many keyboard shortcuts in VC++ that it's hard to tell which of them are useful. Here are a few that I use the most:

Tab and shift-tab:
    Indent and un-indent the selected block of code
    Format the selected block of code with standard indentation
Ctrl-minus and ctrl-shift-minus:
    Navigate backward and forward (like in a web browser)
    Collapse or un-collapse all functions

Clipboard history

It's good practice to avoid copying and pasting code, but if you have to do it, the clipboard history feature can save you a lot of time. By pressing ctrl-shift-v, you access a pop-up menu with the last ten items that you copied, and you can choose which one to paste. If you are copying multiple items from one file to another, this will allow you to do it all in one pass instead of having to switch between files many times.

I also use Visual Assist X a lot, but that really deserves its own post. Are there any other obscure VC++ features or keyboard shortcuts that you use all the time?