Visual Studio

From Schmid.wiki
Jump to: navigation, search

Contents

Properties

Conform to C++98 standard : C/C++:Language:Disable language extensions: Yes (/Za)
Disable exceptions        : C/C++:Code Generation:Enable C++ Exceptions: No

Command-line Usage

Building a project from the command line:

vcvars32.bat
msbuild something.vcxproj

Compiling a single source file from the command line:

vcvars32.bat
cl file.cpp

Or create a BATCH:

@call vcvars32.bat >nul
:: /Zi     = debug information
:: /wd5430 = disable annoying warning from the MS standard library handling disabled exceptions badly
@cl /Zi /wd4530 /nologo %1 %2 %3 %4 %5 %6 %7 %8 %9

Debug from command-line:

vcvars32.bat
devenv /debugexe file.exe

Making a BATCH file for single-command compilation, e.g. mscompile.bat:

@call vcvars32.bat >nul
@cl /nologo %1 %2 %3 %4 %5 %6 %7 %8 %9

Use like this:

mscompile.bat myfile.cpp

Configuration

Default 'Show all files' mode:

Tools:Options:Projects and Solutions:VC++ Project Settings:Solution Explorer Mode = Show all files

Dont' show Output window:

Tools:Options:Projects and Solutions:Show Output window when build starts = false

Forward slash in #include:

Tools:Options:Text Editor:C/C++:IntelliSense:Use Forward Slash in #include ...:True

Build only project on F7:

Tools:Options:Environment:Keyboard: remove F7 for Build.BuildSolution and assign F7 to Build.BuildOnlyProject

Ctrl+U: edit using Vim:

Tools:External Tools:Add
  Command: %PROGRAMFILES%\Vim\vim72\gvim.exe
  Arguments: --remote-tab-silent +$(CurLine) $(ItemPath)
Tools:Options:Environment:Keyboard:Tools.ExternalCommand7 (7 being the external command number of the Vim command)
  Assign Ctrl+U

Disable anti-aliasing: Consolas has some sort of built-in anti-aliasing, so switch to e.g. Andale Mono.

Hotkeys

Setup

Shift+Alt+Enter  fullscreen

Windows

F7               code
Ctrl+W,S         solution explorer
Ctrl+Alt+J       object browser
Ctrl+D,I         immediate window
Ctrl+D,C         call stack
Ctrl+D,L         locals

Editing

F2               Rename symbol
Ctrl+L           Line cut
Ctrl+Shift+Space Show parameter list
Ctrl+Space       IntelliSense
Ctrl+J           Member list
Ctrl+K, Ctrl+D   Format document
Ctrl+Enter       Open line above
Ctrl+Shift+Enter Open line below

Navigation

F12              Go to definition
Ctrl+F12         Go to declaration
Shift+F12        Find all references
Alt+F12          Find symbol
Ctrl+Shift+8     Go back (from definition or whatever)
Ctrl+Shift+7     Go forward again (to definition or whatever)
Ctrl+Shift+F12   Next error

Debug

F9               toggle breakpoint

Debugging DLLs

If you are developing a DLL, it is easier to debug if you compile it as a static library, until it is ready for deployment. Change 'Configuration Type' to 'Static Library (.lib)' temporarily.

Version Control

  • AnkhSVN doesn't work all that well.

Notes Concerning Visual Studio Editions

  • The Windows Forms Designer seems to be accessible only in Common Language Runtime (CLR) projects.
  • Add-ins like ViEmu are only available in Standard and greater editions.

References

Personal tools