![]() |
![]() |
|
|
Here's what an old CMSC 201 Project looks like:
![]() |
![]() |
|
|
Now, Build All should complete successfully. If you look in the directory where your source resides, you'll find additional files used by the Microsoft Visual C/C++ IDE (Debug folder, a *.dsp, *.ncb, *.plg, and possibly a *.opt, and *.dsw file):
If you plan to target multiple platforms, take advantage of conditional compilation. Microsoft VC++ defines WIN32 for you during preprocessing, compile, and link. If using Irix 6.x, the following symbols may be defined: __sgi, __unix, __host_mips, _SYSTYPE_SVR4, __mips, _MIPSEB. Please visit sgi's tech pub page for details or see this page for a best guess. Any inclusions (or guarding) on a Window machine could be accomplished as follows:
#ifdef WIN32 // Something platform specific #endif
Generally speaking, to inline assembly in Visual C++, simply create an asm block as follows:
void Foo(void) { // C/C++ Function Call __asm { // Inline here } }
Two examples: Inline ASM from a C program and calling a C function in ASM. For more reading on techniques available, see Assembler (Inline) Tasks in MSDN (Microsoft Developer's Network) under the Visual C++ Documentation (sorry, no MAN pages):
Microsoft's IDE does not differentiate between lower case and upper case to decide what compiler to use. So a *.C file is the same as a *.c file. The IDE will invoke the C compiler as a best guess. The two ways to invoke the C++ compiler:
/Tcfilename
/Tpfilename
/TC
/TP
The /Tc option specifies that filename is a C source file, even if it doesnt have a .C extension. The /Tp option specifies that filename is a C++ source file, even if it doesnt have a .CPP or .CXX extension. A space between the option and filename is optional. Each option specifies one file; to specify additional files, repeat the option.
/TC and /TP are "global" variants of /Tc and /Tp. They specify to the compiler to treat all files named on the command line as C source files (/TC) or C++ source files (/TP), without regard to location on the command line in relation to the option. These global options can be overridden on a single file via /Tc or /Tp.
By default, CL assumes that files with the .C extension are C source files and files with the .CPP or the .CXX extension are C++ source files.
The following CL command line specifies that MAIN.C, TEST.PRG, and COLLATE.PRG are all C source files. CL will not recognize PRINT.PRG.
CL MAIN.C /TcTEST.PRG /TcCOLLATE.PRG PRINT.PRG
The following CL command line specifies that FOO1.C, FOO2.CXX, FOO3.HUH, and FOO4.O are compiled as C++ files, and FOO5.Z is compiled as a C file.
CL FOO1.C FOO2.CXX FOO3.HUH FOO4.O /Tc FOO5.Z /TP
When editting the program, the MSVC menu will have a Build Menu:
When debugging (running the program), the menu changes to the Debug Menu:
In general, once a workspace exists and your project is running, the three menus you will use are the File Menu, Project Menu, and Build/Debug Menus. The other menus are there to confuse a new user.
By default, MSVC++ will create an application that runs in a DOS box (a command line application). The code to create the command line app is handled by Windows, and is transparent to the programmer. Visual Studio will fork a child process and run your project. No special steps are necessary when creating a generic C/C++ program with main as an entry point. Use the Wizard included with MSVC++ if you'd like to create a Windowed application. In general, its difficult to turn a command line app into a Document\View windowed program (but not impossible).
Also note: do not stop the program by clicking the X in the upper right hand corner of the DOS box. Instead, use Stop Debugging from the Debug Menu (shown below) in Visual Studio (or use SHIFT F5 when MSVC (not the DOS box) has command focus). Win95/98 seems to get ill when a program is stopped using the DOS box.
Other useful commands are:
Last updated by Jeff, 5-16-2000