CodeWarrior軟件與編程的講解(完整版)_第1頁
CodeWarrior軟件與編程的講解(完整版)_第2頁
CodeWarrior軟件與編程的講解(完整版)_第3頁
CodeWarrior軟件與編程的講解(完整版)_第4頁
CodeWarrior軟件與編程的講解(完整版)_第5頁
已閱讀5頁,還剩71頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、CodeWarrior 使用教程第一課 認識 CodeWarriorTranslated from CodeWarriorU.COMCodeWarrior 能做些什么?    當你知道自己能寫更好的程序時,你一定不會再使用別人開發(fā)的應(yīng)用程序。但是常常會發(fā)生這種情況,就是當你寫了無數(shù)行代碼后,卻找不到使得整個程序出錯的那一行代碼,導致根本沒法編譯和鏈接整個程序。這可能更令人灰心喪氣。    本文將告訴你如何使用 CodeWarrior 這一工具解決上述問題。 

2、0;  從現(xiàn)在開始,我們將集中精力學習如何在 CodeWarrior 中使用 C/C+ 進行編程。為了學習本課程,你必須已經(jīng)能夠比較熟練地使用上述兩種語言之一。CodeWarrior 也可以支持 Java 開發(fā),但那是另一門課程的內(nèi)容。本課程僅限于在 Windows 平臺上使用 CodeWarrior 進行的開發(fā)。一旦你精通了 CodeWarrior 編程后,你可以試試在其它平臺上使用 CodeWarrior。本文中討論過的大部分內(nèi)容都

3、可以應(yīng)用到開發(fā) Mac 應(yīng)用程序中。    CodeWarrior 能夠自動地檢查代碼中的明顯錯誤,它通過一個集成的調(diào)試器和編輯器來掃描你的代碼,以找到并減少明顯的錯誤,然后編譯并鏈接程序以便計算機能夠理解并執(zhí)行你的程序。你所使用過的每個應(yīng)用程序都經(jīng)過了使用象 CodeWorrior 這樣的開發(fā)工具進行編碼、編譯、編輯、鏈接和調(diào)試的過程?,F(xiàn)在你在我們的指導下,自己也可以去做這些工作了。    你可以使用 CodeWarrior 來編寫你能夠想象得到的任何一

4、種類型的程序。如果你是一個初學者,你可以選擇編寫一個應(yīng)用程序(比如一個可執(zhí)行程序),比如象微軟公司的文本編輯器 WordPad 這樣的應(yīng)用程序。    應(yīng)用程序可能是最容易編寫的程序了,而那些龐大的商業(yè)軟件,比如象 Adobe Photoshop,Microsoft Word 以及 CodeWarrior 軟件都是極其復雜的。其它類型的程序指的是控制面板(control panels),動態(tài)鏈接庫(dynamic linked libraries,DLLs) 和插件(plug-ins)

5、。我們先來簡單的討論一下這些類型的程序。    在 Windows 中,控制面板程序是一些(通常比較小的)存放在控制面板目錄下的程序,可以在開始菜單的控制面板項中看到它們??刂泼姘鍖嶋H上是設(shè)置系統(tǒng)功能的一個簡單界面,比如可以在控制面板中完成諸如設(shè)置音量和鼠標移動速度這樣一些參數(shù)。    動態(tài)鏈接庫 (DLLs) 提供了一些很有用的被系統(tǒng)和應(yīng)用程序共享的函數(shù)。通常它們都是沒有用戶界面的。    插件 (Plug-ins)

6、0;有點類似于 DLLs,插件也是可供其它軟件使用的小程序,但插件只能被特定的軟件使用。比如說,Photoshop 的插件允許程序員方便地擴展 Photoshop 的功能,而不需要去修改它的源代碼。同樣的,許多 Web 瀏覽器也使用插件來增加功能,或者為了讓你能夠看到頁面上的新的內(nèi)容類型。實際上,有許多程序,包括 CodeWarrior,都使用這種插件結(jié)構(gòu)。    一旦你掌握了 CodeWarior 和你所使用的操作系統(tǒng)的編程接口時,你可以編寫許多其它類型的程序。實

7、際上,本課程也是你深入學習其它編程方法的基礎(chǔ)課程。你已經(jīng)找到了一個最優(yōu)秀的地方開始你的編程之旅。好,現(xiàn)在請坐好,放松,去吸取這門課程的精華吧,你將踏上一條成為一個編程武士的道路!CodeWarrior 入門    CodeWarrior 是一個復雜的應(yīng)用程序,你必須花點時間來了解它的各種各樣的組件和功能。第一課將講述CodeWarrior IDE 的安裝。我們將學習菜單、窗口和其它的一些方面。建議你最好一邊學習本課程,一邊學習使用 CodeWarrior 的集成開發(fā)環(huán)境。我們從運行 CodeWarrior

8、 開始,如果你按照默認方式安裝的CodeWarrior 軟件,那么在 Windows 的桌面上將會有一個該軟件的快捷方式圖標。雙擊該圖標啟動CodeWarrior 的集成開發(fā)環(huán)境。如果在 Windows 桌面上沒有這個快捷圖標(這種情況經(jīng)常發(fā)生),你可以在C:Program FilesMetrowerksCodeWarriorBin 中找到 IDE.exe 文件,然后運行它。工具條啟動 CodeWarrior 后,你將會看到,在屏幕上方的菜單下面有一個工具條。這個工具條(見圖

9、1-1)包含了一些常用菜單項的快捷方式。在后面的章節(jié)中,你將學到如何設(shè)置這個工具條,甚至是整個 IDE 環(huán)境?,F(xiàn)在,你應(yīng)記住,這個工具條用于快捷使用 IDE 中的功能。圖 1-1: CodeWarrior IDE 的工具條文件菜單    CodeWarrior IDE 的菜單是按照標準方式設(shè)置的。其中的文件菜單用于處理和文件相關(guān)的一些操作,比如創(chuàng)建、打開、保存和打印等等。編輯菜單    CodeWarrior 的編輯菜單和其它的 Windows&

10、#160;應(yīng)用程序也很相像。其中包括了剪切、復制和粘貼等操作,以及其它一些使得程序員能夠更方便地管理源碼版面布局的選項。在編輯菜單中還有一個 Preferences 項,我們在這一課的后面將提到它。查看菜單查看菜單(圖1-2)用于安排工具條和其它窗口在 CodeWarrior 環(huán)境中如何顯示的選項。所謂的“其它窗口”包括許多特殊的窗口,比如觀察點(Watchpoints)窗口,表達式(Expressions)窗口,過程(Processes)窗口和全局變量(Global Variables)窗口等。圖 1-2: 查看菜單中的工具條子菜單

11、查找菜單    查找菜單用于在單個文件或硬盤的目錄中查找指定的代碼。你可以使用它來方便地替換文本塊或在你的代碼中搜索指定的項目。即使是在小工程中使用這個工具也非常方便。工程菜單    工程菜單中的工具用于管理 CodeWarrior 工程。一個工程包括組成你正在編寫的程序的所有的文件,包括頭文件、源代碼和庫文件。工程窗口顯示了所有這些文件的名稱。我們將在第二課中深入討論這部分內(nèi)容。調(diào)試菜單    這是在編制程序中最常用到的工具。我們將在第五課中詳細介紹它的

12、使用方法。窗口菜單    用于在 CodeWarrior 環(huán)境管理窗口顯示方式的菜單。幫助菜單    通過幫助菜單可以到網(wǎng)上尋求關(guān)于 CodeWarrior 任何問題的在線解答。夠酷的吧?了解 CodeWarrior 集成開發(fā)環(huán)境的設(shè)置    CodeWarrior IDE 提供了許多設(shè)置以便讓你定制你的工作環(huán)境。當你選擇了編輯菜單中的 Preferences 項時,你將會看到一個設(shè)置對話框(如圖

13、1-3)。在該對話框中,有控制 CodeWarrior 編輯器、調(diào)試器和其它許多功能的界面和行為的選項。在這一節(jié)中,我們將學習這些設(shè)置的使用。圖 1-3:  設(shè)置對話框    你可以在自己的 CodeWarrior 中試試上述這些設(shè)置項。你可以先點擊問號標志,然后點擊你感興趣的項目,就可以得到一個有關(guān)該項目的用途的簡短介紹,也可以從幫助菜單中得到更詳細的信息。通用設(shè)置· 編譯設(shè)置(Build Settings): 選擇是否在執(zhí)行編譯之前保存已打開的源文件,以及有多少

14、內(nèi)存被用于編譯工作;· IDE 之外(IDE Extras): 幾個獨立的設(shè)置。比如指定 CodeWarrior 是否使用一個第三方的文本編輯器因為集成的編輯器并不是很完美,這可以通過指定一個你慣用的編輯器來替代它;· 插件設(shè)置(Plug-In Settings): 供插件開發(fā)商調(diào)試他們的插件;· 隱藏文件夾(Shielded Folders): 在這里指定的文件夾在工程設(shè)計期間,或執(zhí)行查找和比較操作期間,將要被忽略掉。如果在你的工程級有一個巨大的“數(shù)據(jù)”文件目錄,而你又不想讓這些文件降低CodeWarr

15、ior 的操作速度時,這個設(shè)置就很管用了;· 資料樹(Source Trees): 用于指定 CodeWarrior 在編譯程序時用不著的目錄。編輯器設(shè)置· 編輯器設(shè)置(Editor Settings): 幾個用于定制編輯器顯示、管理文本和窗口的設(shè)置項;· 字體和制表符(Fonts and Tabs): 設(shè)置編輯器中的文本大小、字體、制表符和其它顯示設(shè)置;· 文本顏色(Text Colors): 用于指定特定語言元素(比如程序的注釋)在編輯窗口中的顯示的顏色。調(diào)試器設(shè)置· 顯

16、示設(shè)置(Display Settings): 幾個用于定制調(diào)試器顯示的設(shè)置項;· 視窗化(Windowing): 設(shè)定調(diào)試器如何管理它的窗口(比如隱藏所有打開的編輯器窗口);· 全局設(shè)置(Global Settings): 幾個用于定制調(diào)試器在全局層次如何工作的設(shè)置。比如當一個包含了程序調(diào)試信息的文件被打開時,是否啟動這個程序;· 遠程連接(Remote Connections): 允許通過 TCP/IP 進行遠程調(diào)試。這樣,你就可以在地球的另一邊調(diào)試你的軟件了;· Java 設(shè)置/J

17、ava 調(diào)試(Java Settings/Java Debugging): 允許你設(shè)置特定的 Java 編程語言選項。本課程不涉及這部分內(nèi)容。RAD 工具· Layout 編輯器: 幾個用于在 CodeWarrior 中定制快速應(yīng)用程序開發(fā)工具的使用的設(shè)置。    正如你所見到的,CodeWarrior 有許多設(shè)置項和選項。設(shè)置完后點擊“Save”按鈕保存你所作的修改,點擊“Close”按鈕將忽略你所作的所有修改。在進入下一節(jié)課之前,多練習幾次。

18、最后請確認“默認的文本文件格式(Default Text File Format)”(在編輯器設(shè)置面板中)保持為 DOS 設(shè)置。(待續(xù))附原文:Lesson 1: Getting to Know CodeWarriorWhat Will CodeWarrior Do for Me?It can be frustrating to use other people's applications when you know you can make something better. But it can also be frustrating when you hav

19、e a zillion lines of code and can't find the one typo that's making the whole application go kablooey - not to mention getting it all compiled and linked and so on.This is why you are here. And this is why CodeWarrior was created.For now, we'll focus on writing programs in CodeWarrior us

20、ing the C or C+ programming languages. This course assumes that you're pretty comfortable using at least one of these languages. CodeWarrior also supports Java development, but that will be covered in a separate class. This course concerns itself with Windows platform development. Once you get r

21、eally good at programming with CodeWarrior, you can explore the other platforms for which tools have been designed. Much of what will be discussed here can also be applied to developing Mac applications.CodeWarrior automatically checks your code for obvious errors, helps you scan it for less obvious

22、 ones (via an integrated debugger and editor), and then compiles and links the code so that your computer can understand and execute your program. Every application that you have used has been through the coding, compiling, editing, linking, and debugging process, using tools like CodeWarrior. Now y

23、ou can do it too! But we still have to teach you how.Using CodeWarrior, you can write just about any type of program you can imagine. If you are a beginner, you may choose to write an application (also known as an executable) as your first program. You might choose to create something as basic as Wo

24、rdPad, Microsoft's text editor, for example.Applications are probably the simplest type of program to write, though large commercial ones like Adobe Photoshop, Microsoft Word and even CodeWarrior itself are quite complex. Other program types include control panels, dynamic linked libraries (DLLs

25、), and plug-ins. Let's talk about these types for a minute.Under Windows, control panels are those (usually small) programs that are stored in your Control Panels directory and visible in the Control Panel section on the Start menu. The control panel itself is simply an interface to a system-wid

26、e feature, like setting the sound volume or the mouse's motion speed, for example.DLLs supply useful functions that are shared by the operating system and applications. They typically don't have a user interfacePlug-ins are similar to DLLs in that they provide small pieces of code that are u

27、sed by other software. However, a single program typically uses this code. For example, Photoshop plug-ins allow programmers to easily extend the capabilities of the Photoshop application without having access to its source code. Likewise, many Web browsers use plug-ins that add extra features to th

28、e application or allow you to manipulate new content types on the Web. Many programs, including CodeWarrior, make use of this plug-in architecture.There are plenty of other types of programs you can write once you master CodeWarrior and the programming interfaces for your operating system. In fact,

29、once you complete this course, you can take other courses in which you will learn more in-depth methods of programming your computer. You've chosen an excellent place to begin your journey, however. So sit back, relax, and absorb the lessons in this course, and you'll be well on your way to

30、becoming a CodeWarrior!An Introduction to the CodeWarrior ApplicationCodeWarrior is a complex application. If you really want to benefit from all of its features, you should take this time to get to know its various components and the capabilities that will be available to you. This first lesson wil

31、l give you a basic overview of how the CodeWarrior IDE is set up. (That acronym gets thrown around a lot, and it's short for Integrated Development Environment. ) We'll take a look at menus, windows, and other aspects of the program. Follow along with the CodeWarrior IDE while you

32、read through these lessons. Start by launching the IDE application. If you followed the defaults for the CodeWarrior software installation, there will be an icon that represents a shortcut to the program. Double-click on it to start the IDE. If the shortcut icon is absent (these things happen), you

33、can typically find the program at C:Program FilesMetrowerksCodeWarriorBinIDE.exe.ToolbarWhen you launch the CodeWarrior IDE, you'll notice a toolbar attached to the menu at the top of your screen. This toolbar (Figure 1-1) contains buttons that are shortcuts to frequently used menu items. You

34、9;ll learn how to customize this toolbar - and even the entire IDE - in a later lesson. For now, notice that this toolbar can be used to quickly access features within the IDE.Figure 1-1: The CodeWarrior IDE toolbar.File MenuThe menus in the CodeWarrior IDE are set up in a relatively standard manner

35、. The File menu contains choices that manage the care and feeding of files. It has standard items that let you create, open, save, and print files.Edit MenuThe Edit menu will also seem familiar if you use other Windows applications. You'll find commands that cut, copy, and paste text, as well as

36、 a few other options to help programmers more easily manage source code layout. There is also a Preferences item in the Edit menu that we'll discuss later in this lesson.View MenuThe View menu (Figure 1-2) gives you options to manage which toolbars and other windows are displayed in the CodeWarr

37、ior environment. Some of these windows include various specialty windows, such as the Watchpoints window, Expressions window, Processes window, and Global Variables window.Figure 1-2: The Toolbar submenu of the View Menu.Search MenuThe Search menu's commands allow you to locate source code withi

38、n a single file, or within the directories of your hard disk. You can also easily replace large blocks of text or search your source code for references to other source code. These tools can be very handy, even for small projects.Project MenuTools in the Project menu allow you to manage CodeWarrior

39、projects. A project includes all of the files that make up a program you are writing, including its headers, source code, and libraries. The Project window serves as a container for these files. We'll discuss this in more depth in Lesson 2.Debug MenuWhen your source code doesn't do exactly w

40、hat you want it to (or your computer crashes when you run your program), you'll develop a close relationship with the items on the Debug menu. We'll discuss debugging in Lesson 5.Window MenuThe Window menu gives you the basic options to manage cascading and tiling windows in the CodeWarrior

41、environment.Help MenuLastly, use the Help menu to get online help with just about any item in CodeWarrior. Pretty cool setup, huh?Getting to Know IDE PreferencesThe CodeWarrior IDE has numerous preferences that you can use to customize your work environment. You may only want to change the text colo

42、r, or you might want to get more personal, changing lots of settings. When you select Preferences from the Edit menu, you are presented with the IDE Preferences dialog box (Figure 1-3). There, you'll find options that control the appearance and behavior of the CodeWarrior editor, debugger, and l

43、ots more. In this section, we'll take a look at these preferences.Figure 1-3: The Preferences dialog box.As each item is described below, follow along in your own copy of CodeWarrior, and check out the various options available. You can get additional help by clicking on the question mark, then

44、the item you're interested in. You'll see a terse description of the selected item's purpose. More detailed information is also available from the Help menu.The General Preferences· Build Settings: Choose whether to save open-source code files before performing a build and how

45、much memory to use while building.· IDE Extras: Various settings that don't belong anywhere else. Here's where you can have CodeWarrior interoperate with a third-party text editor. The integration of editors with the IDE is often less than perfect, but this limitation may be offset

46、 by the ability to use an editor that you know and like.· Plug-In Settings: Used by plug-in developers to assist in the debugging of plug-ins.· Shielded Folders: Directories listed here are skipped (ignored) during project and/or find and compare operations. This can be useful if

47、 you have a large directory of "data" files inside your project hierarchy yet you do not want those files to slow down certain operations of CodeWarrior.· Source Trees: This lets you specify directories other than the standard ones CodeWarrior searches when it builds a program.Ed

48、itor Preferences· Editor Settings: Various settings to customize the way the Editor displays and manages text and windows.· Fonts and Tabs: Text size, font, tab, and other display settings for the Editor windows.· Text Colors: Like the browser display, you choose the co

49、lor in which certain language elements (such as comments) appear in the Editor window.Debugger Preferences· Display Settings: Various settings to customize the display of the debugger.· Windowing: How the debugger manages its windows (e.g., hiding any open editor windows).·

50、Global Settings: Various settings that customize how the debugger works on a global level, such as whether to launch a program when you open a file that contains the program's debugging information.· Remote Connections: Allows debugging over TCP/IP. You can debug software on a com

51、puter on the other side of the Earth!· Java Settings/Java Debugging: Allows you to set specific java programming language options, not covered in this course.RAD Tools· Layout Editor: Various settings to customize the use of rapid application development tools within CodeWarrior.

52、As you can see, there are numerous settings and options that can be set. Clicking the Save button will save any changes you've made. Clicking the Close box for the Preferences window will cause CodeWarrior to ignore any changes you've made. Go ahead and play with it a little before you proce

53、ed to the next lesson. Make sure the Default Text File Format (in the Editor Settings panel) remains set for DOS.第二課  顯示和定制工程和目標文件(1)Translated from CodeWarriorU.COM    本課將講述 CodeWarrior 操作文件的方式以及介紹它的工程(Project)窗口。什么是工程文件    為了使用 

54、CodeWarrior 來創(chuàng)建一個應(yīng)用程序,你必須創(chuàng)建許多文件來構(gòu)成一個工程(Project)。該工程的設(shè)置和所有這些文件的指針都被存放在一個工程文件中。這些設(shè)置包括編譯和鏈接設(shè)置、源文件、庫文件以及它們之間用于產(chǎn)生最終程序的相互關(guān)系。你可以將這個工程文件看作該工程的大腦:它保存了所有文件相互依存的關(guān)系并知道如何將它們組合成為一個可用的應(yīng)用程序。工程窗口依次顯示了這些關(guān)于你的程序和該程序所包含的文件的信息,并允許你只需輕松點擊就可以修改這個工程。圖2-1顯示了工程窗口的外觀。圖 2-1: 顯示工程信息的工程窗口(圖示為空的情況)   

55、 大多數(shù)組成你的程序的文件都是原始的文本文件。這些文件包含了你在 CodeWarrior 的編輯器中鍵入的源代碼。在某些情況下,你還將使用一些預(yù)編譯的源碼和頭文件。在進行數(shù)學運算和 I/O 操作時,你還要使用到一些庫文件,比如Metrowerks 標準庫(Metrowerks Standard Library,MSL)    通常,你都是使用 C 或 C+ 來編寫源代碼,但通過給 CodewWarrior 的集成開發(fā)環(huán)境加裝相應(yīng)的插件(

56、plug-in),你也可以在 CodeWarrior 中使用其它語言來進行編程。別忘了,CodeWarrior 可是一個可擴展的集成開發(fā)環(huán)境。通過給它安裝一些插件,你就可以擴展它的功能。比如說,加入有人開發(fā)了一種新的叫做 Z+ 的編程語言,你就可以為CodeWarrior 創(chuàng)建一個相應(yīng)的插件使之能夠支持 Z+ 語言,而且你還可以拿這個插件賣好多錢,讓所有使用CodeWarrior 編程的人都使上 Z+ 語言。那該多好!:)    現(xiàn)在你知道了&#

57、160;CodeWarrior 是如何使用文件的了。下面我們來詳細地學習有關(guān)工程窗口的知識。工程窗口當你啟動 CodeWarrior 并打開或創(chuàng)建一個工程時,工程窗口就會顯示出來。該窗口用于管理整個工程的所有文件以及這個工程將要產(chǎn)生的目標(targets)文件。一個工程包含了足夠的信息來編譯一個或多個目標文件。所謂的目標(target)文件就是當你編譯程序時,由 CodeWariior 創(chuàng)建出來的(通常是)一個應(yīng)用程序或庫文件。一些程序可以編譯產(chǎn)生多個目標文件。比如,你可以編寫一個程序來創(chuàng)建一個 DLL 和一個調(diào)用該

58、0;DLL 的主應(yīng)用程序。在 CodeWarrior 的工程中,你可以定義一個目標來產(chǎn)生 DLL,定義另一個目標來產(chǎn)生應(yīng)用程序。通過這種方式,你的工程只需編譯一次就可產(chǎn)生所有需要的目標文件或片斷。圖 2-2 顯示了“Hello World”程序的工程窗口。圖 2-2: Hello World 程序的工程窗口(其中顯示了所有包含于該程序中或用于編譯該程序的文件)    你可以看到,在這個工程窗口中確實包含了一些項目。在窗口的頂端有三個標簽(tab)頁:文件標簽(如圖2

59、-2顯示)、鏈接順序標簽頁和目標文件標簽頁(后兩個標簽頁將在后續(xù)課程中講述)。在這幾個標簽頁的上方,有一個用于選擇要編譯的目標文件的下拉菜單。在本例中,我們選擇的是 Hello World 工程的調(diào)試版本。在下拉菜單的右邊有幾個圖標,它們的存在允許你不必使用菜單命令就可以方便地編譯、鏈接和運行這個工程。注意: 在某些版本的 CodeWarrior 中,鏈接標簽被稱為段(segments)標簽。有些人可能在某些 X86 的處理器上編程時使用的是分段(segmented)代碼。但使用 Windows 版的&#

60、160;CodeWarrior 工具時就不是這樣,這是產(chǎn)生的 X86 代碼使用的是"扁平的"(flat),或者叫做非分段的(unsegmented) 內(nèi)存空間。    顧名思義,文件標簽頁列出了在工程中所有可能用到的文件。你可以通過創(chuàng)建一些組(用文件夾圖標表示)來分門別類地管理這些文件,并可以幫助你方便地了解哪些文件將被使用。在本例中,我們將 C 程序(以.c為后綴名的文件)全都放到一個叫做 Source 的組中,同時將庫文件放到另一個組中,以便整潔明了地

61、管理這些文件。    在 Sources 組中有一個 main.c 文件。因為我們還沒有編譯這個工程,所以在每個文件對應(yīng)的 Code 和 Data 欄中顯示數(shù)字的都是零。一旦我們編譯了這個工程,這些數(shù)字就將顯示出來,表示源碼轉(zhuǎn)換為機器代碼后實際的代碼量和數(shù)據(jù)量??墒?,庫文件 ANSICX86.LIB 和 MWCRTL.LIB 后面顯示的是 n/a 。這表示索雖然這些文件被顯示在這里,但是它們并不是 Hell

62、o World 目標文件的一部分。這兩個文件是用于不可調(diào)試(non-debugging)開發(fā)的,而本例不是這種情況。如果我們從菜單中修改本例的目標文件為 Release(發(fā)布) 版本時,這兩個文件就用得上了。這時這些文件后面的Code 和 Data 欄目就會顯示相應(yīng)的數(shù)值。注意 : 在 Data 和 Code 欄右端的 Target 欄目中的小子彈頭也是用來表示該文件是否被當前編譯生成的目標文件使用到。    再往右

63、邊去,是 Debug 欄(用一個綠色的小蟲子表示),它是用于告訴你對應(yīng)的文件在編譯時是否要產(chǎn)生調(diào)試信息。我們將在第五課中詳細論述這部分內(nèi)容。最后,我們來看看在每一行最右端的彈出菜單,它是用于打開文件、更新源碼、打開包含的頭文件等等操作的快捷方式,具體是什么才作,要看它所代表的項目的類型而定?,F(xiàn)在讓我們來編譯這個 Hello World 工程并看看編譯后的工程窗口的情況。我們從 Project 菜單中選擇 Make 命令來編譯該工程。這將更新所有需要編譯的文件并產(chǎn)生相應(yīng)的輸出文件在本例中是 Hello Wo

64、rld 這個應(yīng)用程序。圖 2-3: 編譯工程后的工程窗口的顯示情況從圖2-3中我們可以看到,工程窗口發(fā)生了一些變化。Code 和 Data 欄都顯示了當前工程中對應(yīng)項的相應(yīng)的數(shù)字。如果你打算看看編譯前后存放這些文件的目錄的話,你會發(fā)現(xiàn)編譯后在該目錄下產(chǎn)生了一些新的文件,如圖2-4所示。圖 2-4: 編譯后將在工程目錄中產(chǎn)生一些新的文件    在本例中,編譯工程后在工程目錄中產(chǎn)生了一個新的文件。這就是 X86 目標文件輸出生成一個叫做 Hello

65、World x86 的應(yīng)用程序。其它一些一直存在于這個目錄中的文件是: .mcp 文件工程文件本省,以及 .c 源文件包含了應(yīng)用程序源碼的文件。Hello World Data 目錄中還包含了由 CodwWarrior 生成的各種各樣的支持文件?,F(xiàn)在你還不必去關(guān)心這些文件。如果你正在編譯目標文件的調(diào)試版本,你會看到更多的文件被產(chǎn)生出來,這些文件中可能包含著符號(symbolic)調(diào)試信息。集成開發(fā)環(huán)境的調(diào)試器使用這些符號信息來記錄在高層次源碼中的操作軌跡。我們將在第五課中詳細講述這方面內(nèi)容。  

66、  現(xiàn)在你已經(jīng)了解了這些文件是如何結(jié)合在一起被編譯生成一個目標文件的。讓我們來運行這個目標文件并看看它的運行結(jié)果是什么樣。你雙擊 Hello World x86 應(yīng)用程序,就會有如圖 2-5所示的結(jié)果顯示出來。圖 2-5: Hello World 應(yīng)用程序的運行結(jié)果你來試試看    總有一天,你自己也能編寫出象 Hello World 這樣充滿激情和意義深遠的程序來。這是完全有可能的。只要你有決心努力工作,學完本課你就可以編寫這個程序了。下面我們給出該程序的源代碼:#include void main(void)     int c;    printf("Hello World on Windows!n&qu

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論