CST8152 Compilers Creating a C Language Console Project with Microsoft Visual Studio.Net 2010

Similar documents
CST8152 Compilers Creating a C Language Console Project with Microsoft Visual Studio.Net 2005

CST8152 Compilers Creating a C Language Console Project with Microsoft Visual Studio.Net 2003

TREX Set-Up Guide: Creating a TREX Executable File for Windows

Opening Microsoft Visual Studio. On Microsoft Windows Vista and XP to open the visual studio do the following:

Introduction. Key features and lab exercises to familiarize new users to the Visual environment

WRITING CONSOLE APPLICATIONS IN C

Module 3: Working with C/C++

Visual C++ Tutorial. For Introduction to Programming with C++ By Y. Daniel Liang

HOW TO USE CODE::BLOCKS IDE FOR COMPUTER PROGRAMMING LABORATORY SESSIONS

Using OpenGL & GLUT in Visual Studio.NET 2003

Creating a MOM 2005 Peformance Graph Report From a Template

Building AMD64 Applications with the Microsoft Platform SDK. Developer Application Note

Quick Start Guide ZedboardOLED Display Controller IP v1.0

Session 10 MS Word. Mail Merge

CSCI 161: Introduction to Programming I Lab 1b: Hello, World (Eclipse, Java)

Start Mail Merge Step by Step Mail Merge Wizard messages

RVDS 4.0 Introductory Tutorial

Creating a new CDC policy using the Database Administration Console

Applied ICT Skills MS Windows

Ticket Mail Merge Instructions for MS Word 2007 and 2010

CPE 323: Laboratory Assignment #1 Getting Started with the MSP430 IAR Embedded Workbench

RVDS 3.0 Introductory Tutorial

BASICS OF THE RENESAS SYNERGY PLATFORM

4H4Me Announcement Letter

At the shell prompt, enter idlde

How to debug Wcem.dll with.net Studio

Module 4: Working with MPI

IMPLEMENTING SCL PROGRAMS. Using Codeblocks

Creating Mixed Language Projects with Microsoft Developer Studio 2005, Intel Fortran, MS C++ and Canaima Legacy Software

CodeWarrior Development Studio for Advanced Packet Processing FAQ Guide

Use Vivado to build an Embedded System

Creating Pages with the CivicPlus System

Windows NT Server Printer Driver Upgrade Instructions

Using the Dev C++ Compiler to Create a Program

OrgPublisher Photos, Logos, and Legends

INFORMATICS LABORATORY WORK #2

Mail Merge. To Use Mail Merge: Selecting Step by Step Mail Merge Wizard. Step 1:

Where Did My Files Go? How to find your files using Windows 10

Pursuit 7 for Windows

Colligo Contributor Pro 4.4 SP2. User Guide

Lab 1: Introduction to C Programming. (Creating a program using the Microsoft developer Studio, Compiling and Linking)

Prototype User Guide Public Release Version 1

IT Essentials v6.0 Windows 10 Software Labs

Project. A project file contains the following information:

and 32 bit for 32 bit. If you don t pay attention to this, there will be unexpected behavior in the ISE software and thing may not work properly!

EECE.2160: ECE Application Programming Spring 2018 Programming Assignment #1: A Simple C Program Due Monday, 1/29/18, 11:59:59 PM

Configuring Visual Studio 2017 with SFML Game Engine

OOSIML SIMULATION MODELS. On Windows and Linux

PrimalScript. Your First 20 Minutes. Your First 20 Minutes. Start here to be productive with PrimalScript in just 20 minutes.

Lab 4: Introduction to Programming

Getting Started with Visual Studio

Editing your SiteAssist Professional Template

Exercise 7-1 Preparing Files for Distribution

Optional Eclipse Workspace Configurations

Using Eclipse for Java. Using Eclipse for Java 1 / 1

Engr 123 Spring 2018 Notes on Visual Studio

Parallel Printers Set-Up

APPENDIX A. CODE COMPOSER STUDIO (CCS) v5: A BRIEF TUTORIAL FOR THE DSK6713

As CCS starts up, a splash screen similar to one shown below will appear.

'phred dist acd.tar.z'

Netherworks Studios. Start DAZ Studio 3 and simply navigate to "NWS Scripts" in your content folder. Run the "Activate Folder Favorites" script.

SITE DESIGN & ADVANCED WEB PART FEATURES...

Use Vivado to build an Embedded System

Business Insight Authoring

10ZiG Technology. Thin Desktop Quick Start Guide

Test/Debug Guide. Reference Pages. Test/Debug Guide. Site Map Index

As CCS starts up, a splash screen similar to one shown below will appear.

MAIL MERGE LABELS USE THE MAIL MERGE WIZARD

Welcome Application. Introduction to C++ Programming (Solutions) 2004 by Deitel & Associates, Inc. All Rights Reserved.

NetBeans Tutorial. For Introduction to Java Programming By Y. Daniel Liang. This tutorial applies to NetBeans 6, 7, or a higher version.

Tutorial 2 - Welcome Application Introducing, the Visual Studio.NET IDE

Lab 0 Introduction to the MSP430F5529 Launchpad-based Lab Board and Code Composer Studio

HPC on Windows. Visual Studio 2010 and ISV Software

Installing and getting started with Visual Studio for C programming in Windows.

DOMAIN TECHNOLOGIES. Getting Started Guide Version 1.1. BoxView IDE. Integrated Development Environment

Developing Intelligent Apps

Code::Blocks Student Manual

A QUICK OVERVIEW OF THE OMNeT++ IDE

Working with Mailbox Manager

Hello World on the ATLYS Board. Building the Hardware

POS Designer Utility

Supplement H.1: JBuilder X Tutorial. For Introduction to Java Programming, 5E By Y. Daniel Liang

Using Eclipse for C, MPI, and Suzaku

DEVELOPING OOSIML SIMULATION MODELS. Using Codeblocks

Supplement II.B(1): JBuilder X Tutorial. For Introduction to Java Programming By Y. Daniel Liang

Eclipse Quick Reference Windows Hosted

For additional information, please consult the Read-Me and Help documentation or contact Electro-Voice or Dynacord technical support.

APPLICATION COMMON OPERATING ENVIRONMENT (APPCOE)

UNic Eclipse Mini Tutorial (Updated 06/09/2012) Prepared by Harald Gjermundrod

BASIC USER TRAINING PROGRAM Module 4: Topology

CaliberRM 5.1 Integration for Describe Enterprise

Dealing with Event Viewer

DocAve Content Shield v2.2 for SharePoint

Visual Studio.NET. Although it is possible to program.net using only the command OVERVIEW OF VISUAL STUDIO.NET

SQL Server 2005: Reporting Services

CodeWarrior Development Studio for Power Architecture Processors FAQ Guide

Prerequisites for Eclipse

Code Composer Studio Operation Manual

Click on the Start Icon. Click on All Programs

Compiling MapleSim C-Code in Visual C Express

Transcription:

CST8152 Compilers Creating a C Language Console Project with Microsoft Visual Studio.Net 2010 The process of creating a project with Microsoft Visual Studio 2010.Net is similar to the process in Visual Studio 2008.Net, but Microsoft added a few more options and changed the user interface at some places. To create a C Language Console Project, you should follow the steps outlined below. 1. Getting Started Launch Microsoft Visual Studio.Net 2010. After the greeting flash screen disappears you should be presented with the Microsoft Development Environment [design] window. Depending on the installation configuration the window can contain different views. By default it should display the Start Page view. If the Start Page is missing, you can invoke it from the main menu bar opt for Window, Reset Window Layout, Yes. The screen could look a bit different from the one shown in Figure 1 if you have already created some projects they will be listed in the Projects tab list. You can also see some other views displayed. Figure 1. Microsoft Development Environment Start Page view displayed. CST8152 Compilers Page 1 of 13

2. Creating a project - Selecting a Project Type Close the Start Page view window and select File, New, Project from the main menu bar. The following New Project window should appear. Select Visual C++ in the left pane (Installed Templates) and Win32 Console Application in the right pane (Templates). Enter the name of the project in the Name text filed, for example, cdtypes. Choose the location of the project. You can use the default one or you can change to something more memorable. For example, C:\Compiler\Lab0. Uncheck Create directory for solution check box. The screen should look like the one shown below in Figure 2. Click OK. The Win32 Application Wizard should appear as shown in Figure 3. Figure 2. Selecting the Project Type and Naming the Project. 3. Creating a project - Selecting an Application Type In the Win32 Application Wizard click the Application Settings on the left. The Application Wizard window should change as shown in Figure 3a. CST8152 Compilers Page 2 of 13

Figure 3. Selecting Application Settings. Make sure Console application is selected as an Application type. Uncheck the Precompiled header option, and check Empty project under Additional options as shown in Figure 3a. Click Finish. The Solution Explorer view should appear on the right. If not, choose View, Solution Explorer from the main menu. Figure 3a. Selecting Console Application. In the Solution Explorer view window you should see your project node tree. It contains four folders: External dependencies, Header Files, Resource Files, and Source Files as shown in Figure 4. If you try to CST8152 Compilers Page 3 of 13

open some of the folders, you will find that they are empty. You can remove the Resource Files node. Select Resource Files, right-click, select Remove and confirm with OK. Figure 4. An Empty Project in Solution Explorer If you do not like the name of the project, you can change it. Simply select Solution, right-click, select Rename and type the new name of the project. Then, select the cdtypes project node, right-click, select Rename and type the new name. 4. Setting the Project Properties Before setting the project properties a C/C++ program file must be added first. Otherwise C/C++ option will not be visible in the right pane of the Project Properties window. To add a new file you should right click on the Source Files folder (or on the project name cdtypes) and select Add, Add New Item. Select Code in the right pane, and C++ File(.cpp) in the left pane. Type the name of the file in the Name: <Enter Name> field. The file extension MUST BE.c. Click the Add button at the bottom. The program editor view should appear on the right. Section 5 explains in more details how to add a new or existing file. The next step is to set the project properties. Select cdtypes project node in Solution Explorer. Then select Project, Properties from the main menu (or right-click on cdtypes project name and select Properties. The Property Pages window should appear as shown in Figure 5. On the left side you will see the Configuration Properties tree. The currently selected property is highlighted in grey. On the right side you can see the default settings. When the window opens the General property should be selected by CST8152 Compilers Page 4 of 13

default (see Figure 5.). Clicking on the + icons you can expand the tree node and choose and configure different setting of your project as shown below with the C/C++ node expanded. Figure 5. The Property Pages Window. To change a configuration parameter (or property) you must select the corresponding line, click on the pull-down list icon to reveal the list of allowed options, and select the appropriate one as shown in Figure 6. Figure 6 show how to change the Character Set property to Not Set. Once you are done with the page, you should click Apply and move to the next page. You can use this property page to change the Target Name. The target name is the name of the executable file generated by the compiler/linker. By default the target name is the name of the project. If you want to change it, select the line and click on the pull-down list icon to reveal the list of allowed options. Select <Edit>, type the name of the target in the Target Name dialog box and click the OK button. CST8152 Compilers Page 5 of 13

CST8152 Compilers Page 6 of 13

Figure 6. Configuration Properties, General changing Character Set property. 4.1. Changing the C/C++ Project Properties (settings) Click on the + icon in front of the C/C++ node. The C/C++ property nodes will appear as shown in Figure 7. Select the General property page. In Figure 7 the default Warning Level property - Level 3 (/W3) is changed to Level 4 (/W4). No changes are required in Optimization, Preprocessor, Code Generation, Precompiled Headers, Output Files, and Browse Information. You can peruse the property pages for further reference. CST8152 Compilers Page 7 of 13

Figure 7. C/C++ Property Pages Warning level changed in General Go to Language, select Disable Language Extension and select Yes(/Za) as shown in Figure 8. This will force the compiler to be ANSI C compliant, and if your program contains any non ANSI C language statements (extensions) the compiler will generate syntax errors or warnings. For example, if you have C++ type single line comments (//) which are not allowed in ANSI C, the compiler will generate warnings like the one shown bellow CST8152 Compilers Page 8 of 13

Figure 8. Making the compiler ANSI compliant. Move to the Advanced page. Change Compile As from Compile as C++ Code (/TP) to Compile as C Code (/TC) as shown in Figure 9. Figure 9. Forcing the C++ compiler to work as a C language compiler. CST8152 Compilers Page 9 of 13

Take a look at the Command Line option. Do not change anything there. 4.2. Changing the Linker Project Properties No any changes are required for the Linker Properties. In Linker, General you can change the name of the executable file which will be generated by the linker. Note: If you want to change the name of the project (output exe file) you must make the change in Linker, General, Output File using the <Edit > option. Explore the Linker properties. 4.3. Changing the Other Project Properties You can explore the rest of the property pages, but there is no need to change any of the default setting for this particular project. So click Apply and OK to finish with the project properties configuration. Select File, Save All to save the project settings. 5. Adding Source Code to your Solution (Project) To add a C program to your project, select Source Files in Solution Explorer pane, right-click, select Add. Now you have the option to add a new program file or an existing program file as shown in Figure 10. If you program or header file dos not exist, you can add a new item to your project. Select Add New Item and in the Add New Item window select Code folder icon on the left, select the C++ File or Header File on the right, type the name of your source file in the Name text filed as shown in Figure 12. Click Add and the file will be added to your project (Figure 11) and an empty program editor will appear on the screen. If it has not, double click the cdtypes.c program file name. You can type your program now. If you program has been already written, before performing the add operation, you should copy the file into the project directory. After selecting Add Existing Item the Add Existing Item window will appear and you can select the c-file from the list. Click Add and the file will be added as a subnode to your Source Files folder as shown in Figure 11. Now you can start working with your program. Figure 10. Adding a Source Code Item Figure 11. A Program is Added to the Project. CST8152 Compilers Page 10 of 13

Figure 12. Adding a New Source File. 5. Compiling a C program In Solution Explorer select the C file you want to be compiled, right-click and select Compile (or press Ctrl-F7). The result of the compilation will be shown in the Output view. The Compile action creates an object file only, not an executable. Pay attention to the warnings. 6. Building a Project To build a project means to make a request to the IDE to compile all your project files (c and h) and to link the compilation results (the obj file) into an executable (.exe). To build a project, select the project node (for example, cdtypes) in Solution Explorer view, right-click, and select Build. You can use the Build option from the main menu for the build the project (or the solution).the results from the building process will be reported in the Output view. If the operation of building the project is successful, an executable file will be created in your project Debug directory. Pay attention to the warnings. Note: If the compiler gives you a warning C4001 in file sal.h, ignore the warning. This warning is caused by a bug in one of the Visual studio header files. Pay attention to all other warnings. 7. Running the Program You can run your program within the IDE, or as a stand alone program from the command prompt in a Command Prompt (DOS or console) window. CST8152 Compilers Page 11 of 13

To run the program within the IDE, select Debug, Start Without Debugging (Ctrl+F5). The result of the execution will be shown in an application window. If your program requires command line arguments, you must specify them in the project Properties, Configuration Properties, Debugging properties page. Select Command Arguments, click on the down arrow, and select <Edit > as show in Figure 13. Enter the arguments in the text filed of the Command arguments window. Clock OK. Figure 13. Specifying Command Line Arguments To run the program from the command prompt (which is the normal way of invoking (running) a console application) you need to open a Command Prompt window. To open a Command Prompt window in Windows 7 select Start, Run, type cmd or command, and click OK. In Windows 8 launch the Search charm and type cmd. Click on CST8152 Compilers Page 12 of 13

Once you have the command prompt window opened, use the cd command to navigate to the Debug folder, which is inside your project directory. The standard location of the Visual Studio projects is c:\users\<your user name>\documents\visual Studio 2010\Projects\. You can see the actual project path in the Properties window. If you do not see the Properties window within the IDE, select from the main menu View, Other Windows, Properties Window. Once you make the Debug folder current, type the name of your executable (for example, cdtypes) and the command line arguments and press Enter. Now it is time to close the Net and count the fish. Enjoy it. S^R, 2013 CST8152 Compilers Page 13 of 13