PDF file - users.etech.haw

Transcription

PDF file - users.etech.haw
Visual Studio 2010 Professional
including Service Pack 1
Erste Schritte
1.) Um beim Anlegen eines Projektes im Homedirektory folgende Fehlermeldung zu vermeiden,-
empfiehlt es sich folgende Einstellung als erstes vorzunehmen.
Tools \ Options \ Text Editor \ C/C++ \ Advanced \ Fallback Location
Set <Always Use Fallback Location>
from <False> to <True>
Set <Do Not Warn If Fallback Location Used>
from <False> to <True>
Set <Fallback Location>
to <"%USERPROFILE%\Local Settings\Temp\VC++">
Erklärung:
The message is safe to ignore, what that is saying is that for performance reasons it won't use the solution
directory to store the intellisense database because it is on a network share.
2.) Folgende MessageBox erscheint beim Öffnen einer bestehenden Solution:
Tipp: Den Haken bei der Checkbox entfernen!
3.) Der Button <Browse...> versteckt Netzwerklaufwerke unter Windows XP:
Beim Erstellen eines Projektes sollten Sie im Feld <Location> erst "H:\" eingeben,
bevor Sie den Button <Browse...> benutzen. Dann wird auch das HomeDirektory sichtbar.
Das ist der sicherste Platz für Projektdaten im Netz.
Was auf C:\ liegt kann leicht verloren gehen.
Erstellen eines leeren Projekts
File \ New \ Project...
Installed Templates \ Visual C++ \ Win32 \ Win32 Console Application
Create directory for solution:
Add to source control:
Name:
Location:
Disable
Disable
<Ihr Projektname>
<Projektpfad> Empfehlung: "H:\VC2010\PRP1"
=> OK
Welcome to the Win32 Application Wizard
=> Next (!!!)
Application type:
Console application
Additional options:
Empty project:
Precompiled header:
Add common header files for:
ATL:
MFC:
=> Finish
Enable
Enabled
Disabled
Disabled
Einem bestehenden Projekt eine Quellcodedatei hinzufügen
Project \ Add New Item...
Installed Templates \ Visual C++ \ Code \ C++ File (.cpp)
Name: <IhrName>
=> Add
Beispielprogramm:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
printf("\n Hello World \n");
return 0;
}
Empfehlung: Sofort Speichern mit <Save> oder <Save All>
Compilieren
CTRL+F7 oder
Rechts Klick auf <IhrName.c> \ Compile
Compilieren und Linken
F7 oder
Rechts Klick auf <Ihr Projektname> \ Build
Programm starten
CTRL+F5 oder
Debug \ Start Without Debugging
F5 oder
Debug \ Start Debugging
Umgang mit unnötigen Warnungen und Problemen
Problem: Warning C4996: 'scanf': This function or variable may be unsafe.
Lösung:
Im Projekt ist folgende Änderung durchzuführen:
Project \ Properties (Alt+Return)
Configuration Properties \ C/C++ \ Preprocessor
Click on Preprocessor Definitions \ <Edit...>
Add: _CRT_SECURE_NO_WARNINGS
Von nun an ist diese Art Warnung bezogen auf
die Projektkonfiguration (Debug / Release) ausgeschaltet.
Problem: ▪ Warning LNK4099: PDB 'vc100.pdb' was not found with 'xyz.obj' or
at 'H:\VCPP\...\Debug\vc100.pdb'; linking object as if no debug info
▪ Or if it's not possible to Watch a variable or an array during a debug session
as long as the Solution is located on a network folder.
Cause:
VS 2010 is wrongly naming the "Program Database File Name"
and is even placing the file into the wrong location.
Solution: Change the following Project Settings:
Project \ Properties (Alt+Return)
Configuration Properties \ C/C++ \ Output Files
Change "Program Database File Name"
from: $(IntDir)vc$(PlatformToolsetVersion).pdb
to:
$(OutDir)$(TargetName).pdb
Now delete the Projects Debug folder, and Compile and Link the Project.
From now on the linker warning is gone and variables and arrays can
be watched during a debug session again.
How do I 'clean' a Visual Studio 2010 C++ solution, so that it is
small enough to be zipped up and sent as an email attachment?
•
Delete the Debug folder themselve.
Notice: If some files have been manually put in the bin folder by the developer for the program to
work make sure you don't delete it. If it's not your own project: Normally there are files of type exe,
pdb, ilk, lib, dll, exp, vshost.exe, manifest, that can be safely deleted. But if you see other things,
such as mdf or mdb databases, images, text files, etc they shouldn't be deleted.
•
At the root of the solution or project there might be a big .ncb file which is Intellisense's database
and can be safely deleted since it is recollected next time you open the project. A user options file
with .suo is there that contains the environment and editor's layout and settings. This can be
deleted too but it's usually small.