教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 学前教育 >

CodeWarrior 使用教程(3)

来源:网络收集 时间:2026-02-20
导读: 正在编译目标文件的调试版本,你会看到更多的文件被产生出来,这些文件中可能包含着符号(symbolic)调试信息。集成开发环境的调试器使用这些符号信息来记录在高层次源码中的操作轨迹。我们将在第五课中详细讲述这方

正在编译目标文件的调试版本,你会看到更多的文件被产生出来,这些文件中可能包含着符号(symbolic)调试信息。集成开发环境的调试器使用这些符号信息来记录在高层次源码中的操作轨迹。我们将在第五课中详细讲述这方面内容。

现在你已经了解了这些文件是如何结合在一起被编译生成一个目标文件的。让我们来运行这个目标文件并看看它的运行结果是什么样。你双击 Hello World x86 应用程序,就会有如图 2-5所示的结果显示出来。

图 2-5: Hello World 应用程序的运行结果

Putting It into Play

Someday, you too may create something as lyrical and profound as Hello World. Possibly, with hard work and determination, you can do this by the end of the day. The source code to make this work is as follows:

#include

void main(void) { int c; printf(\getchar(); }

That's it! Who knew it could be so easy? Go on, you know you want to try it, but with some sort of profound statement instead of \applications that not only can display text but can also perform other tasks for you. Before you know it, you'll be customizing AIBO dogs! That's Lesson 4. Well, okay, not really. Lesson 4 is Linking.

What's That Other Function Doing There?

Those already seasoned in the C language might be wondering what the character input function, getchar(), is doing here. Typically, when an application completes its job, it terminates, and the OS cleans up after the program. This means the Hello World window disappears moments after the application finishes drawing the phrase \Windows!\it wait for a final keystroke before it terminates.

This is not a bug, but normal behavior. Honest. CodeWarrior does provide an alternate library that provides the C console I/O functions used here. This alternate library will not only halt the application after it finishes writing to a window but will also let you save the text output to a file.

Link Order

When you build a program using multiple source files, the link order is very important. After compiling your source code, you must link the items in the proper order. You will use the Link

Order tab to determine this order. In the case of the Hello World x86 target we've been working with (Figure 2-6), note that the main.c source file is first on the list, with the libraries used by the program following. To reach the Link Order tab, open the project and click the tab. To change the order by which files are linked, you simply drag items up and down the list within this window. We will discuss Linking in more detail in Lesson 4.

Figure 2-6: Back in the Project window, clicking the Link Order tab displays a list of component files included in the current project.

Targets

Figure 2-7: The Hello World project's Target tab.

After you've chosen the files and defined their link order, you must configure the target. The target is essentially the output file -- in our case, the Hello World application. There are also a lot of settings that must be set behind the scenes to make it possible for you to hit the target. If you double-click the Hello World target in the Targets Tab (Figure 2-7), you should see the dialog box shown in Figure 2-8.

Figure 2-8: Set targeting preferences in the Settings window.

Configuring Target Settings

The preferences you learned about in Lesson 1 are global settings used throughout the CodeWarrior IDE. Now, let's take a look at options for configuring target options. I will briefly examine the most important of these options. Follow along in your copy of CodeWarrior by double-clicking an item under the Target tab to bring up the Settings panel.

If you want a little extra guidance, move your cursor over an item in the panel, right-click it, and read the pop-up help text that appears.

Note: Some of the items listed below are specific to the target we are currently viewing, in this case the Hello World target. If you're using AMD's K6 or Athlon processors, some of these panels may contain items that use features specific to that chip. Consult the documentation for the

compiler/linker that you are using to ensure that you are making the best use of your development environment.

Target Preferences

Target preferences include the following items, each with its own panel:

?

Target Settings: Choose the target's name (the name that appears in the target pop-up menu), which linker(s) to use, and the output directory here. ?

Access Paths: Access paths tell CodeWarrior where to search for required files that are a part of the project but not necessarily project-specific (such as header files).

CodeWarrior will not, by default, search your entire hard disk for files. It will only look where you explicitly tell it to look with access paths. ? ?

Build Extras: A few miscellaneous settings to improve the build speed. Runtime Settings: In order to debug non-application code, such as a plug-in, you must have an application assist you. The application does this by calling the suspect plug-in code. This panel lets you specify the host application to use in this situation. This topic will be mentioned in Lesson 8. ?

File Mappings: Every file must be mapped so as to identify it to the compiler. That is, this panel tells CodeWarrior that files ending in .cpp are C++ source files and should therefore be compiled using the C++ compiler. See Figure 2-9 for more examples.

Figure 2-9: The File Mappings options allow you to specify the treatment of files, based on their extension.

? Source Trees: Source trees are similar to access paths. Here you can enter file locations, such as file servers, that are specific to your project.

? x86 Target: This panel allows you to set the type of project (application, library, or DLL), and various aspects of the project -- including how much …… 此处隐藏:6921字,全部文档内容请下载后查看。喜欢就下载吧 ……

CodeWarrior 使用教程(3).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/593504.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)