CPlusPlus

From BarikWiki
(Redirected from C++)
Jump to: navigation, search

Overview

Cplusplus.jpg

Quickly jump to StarCraft, which is the main reason for using C++ in the first place. It's recommended to have two compiler suites under Windows: Visual Studio and gcc; the latter can be installed using mingw.

Not everyone wants or needs to use a managed code environment, and C++ doesn't seem to be going away any time soon. Why in such a rush? Teach Yourself Programming in Ten Years.

warning: auto-importing has been activated without 
--enable-auto-import specified on the command line.

Can use (Why does it happen?):

-Wl,--enable-auto-import

Visual Studio 2010 (and 2008)

In previous versions of Visual Studio, CTRL + F5 (Start Without Debugging) would pause a command-line application with "Press any key to continue". It appears that this no longer happens automatically with Visual Studio 2010.

Most sources on the web will tell you to change your subsystem, but that doesn't really mean much. Here's a better set of instructions:

  1. . Right-click on your Project Name.
  2. . Select Properties.
  3. . Choose Configuration Properties >Linker > System.
  4. . For the Subsystem property, click the drop-down box.
  5. . Select Console (/SUBSYSTEM:CONSOLE).

Now the console will pause with "Press any key to continue . . ."

  • When copying (replicating) a project, you need to change the GUID. You can do this by manually editing the vcproj file and removing the ProjectGUID It will get generated automatically on next load.
  • You can use Visual Assist X to drastically improve productivity within Visual Studio when working with C++ projects. Unfortunately, even the academic pricing is somewhat expensive. Also, I'm running into the same redraw bug as some other people.
  • It is convenient to be able to copy DLLs to the output folder after building the project. You can do this with Pre/Post-Build Events. See MSDN on how to specify build events.

MinGW

 c:\MinGW\bin>mingw-get.exe install gcc
 mingw-get.exe: *** WARNING *** 
   c:\MinGW\var/lib/mingw-get/data/profile.xml: 
   user configuration file missing

Optional: find defaults.xml and just copy it over to profile.xml (see this Google Doc). This will get rid of the annoying warning.

Boost

Compiling from the Command Line

cl /EHsc basic.cpp

C++ Primer Plus, 5th Edition by Stephen Prata

The book home page. Most people don't recommend this book.

I haven't found an official errata for this, but here is mine:

  • p. 115 (Chapter 4: Compound Types) says char bird[10] = "Mr. Cheeps";. This should instead be char bird[11] = "Mr. Cheeps". The characters can't fit otherwise once you include the implicit \0.

Accelerated C++ by Andrew Koenig and Barbara E. Moo

This book seems to be more highly recommended. The home page is here. NCSU library has this.

Other Tidbits

Visual Studio 2008 Express

Visual Studio 2008 Service Pack 1

An earlier version of Microsoft Visual Studio 2008 has been detected on the system that must be updated to SP1 before installation can proceed.

Including a DLL when Debugging

  • You probably want to do this so that you can integrate with Lua.