📄 显示和定制工程和目标文件(1).htm
字号:
size=2> </FONT><FONT size=2>总有一天,你自己也能编写出象
</FONT><FONT face="Arial, Helvetica, sans-serif" size=2>Hello World
</FONT><FONT
size=2>这样充满激情和意义深远的程序来。这是完全有可能的。只要你有决心努力工作,学完本课你就可以编写这个程序了。下面我们给出该程序的源代码:</FONT></P>
<BLOCKQUOTE><FONT face="Arial, Helvetica, sans-serif" size=2>
<P>#include <STDIO.H><BR>void main(void) { <BR> int c;
<BR> printf("Hello World on Windows!\n");
<BR> c = getchar(); <BR>}</P></FONT></BLOCKQUOTE>
<P><FONT face="Arial, Helvetica, sans-serif"
size=2> </FONT><FONT
size=2>就这么多!你没想到会这么简单吧?你可以试试看将 </FONT><FONT
face="Arial, Helvetica, sans-serif" size=2>"Hello World on Windows!"
</FONT><FONT
size=2>这句话换成一句别的什么内容。要不了多久,你就能自己编写一些不仅能显示文本而且还能执行你指定的其它任务的应用程序了。但在此之前,你还需要学习第四课,有关链接的知识。</FONT></P>
<P><B><FONT face=幼圆 size=+1>关于</FONT><FONT face=Arial
size=+1>getchar()</FONT><FONT face=幼圆 size=+1>函数</FONT></B></P>
<P><FONT face="Arial, Helvetica, sans-serif"
size=2> </FONT><FONT size=2>那些有经验的 </FONT><FONT
face="Arial, Helvetica, sans-serif" size=2>C </FONT><FONT
size=2>程序员可能会问,上述代码中使用的 字符输入函数 </FONT><FONT
face="Arial, Helvetica, sans-serif" size=2>getchar() </FONT><FONT
size=2>用在这里是什么意思。通常地,当一个应用程序执行完毕后,它就会终止,然后操作系统就会立即清除该应用程序输出。这样,当上述应用程序显示完“</FONT><FONT
face="Arial, Helvetica, sans-serif" size=2>Hello World on
Windows!</FONT><FONT size=2>”后,为了避免系统立即将该程序地输出清除,我们在程序中添加了一个
</FONT><FONT face="Arial, Helvetica, sans-serif" size=2>getchar()
</FONT><FONT
size=2>函数,使程序在此处暂停,直到有键盘输入时整个程序会终止。这样我们才有足够的时间来看清楚该程序的输出。</FONT></P>
<P><FONT face="Arial, Helvetica, sans-serif"
size=2> </FONT><FONT size=2>这是一个正常的操作,而不是一个
</FONT><FONT face="Arial, Helvetica, sans-serif"
size=2>bug</FONT><FONT size=2>。实际上,</FONT><FONT
face="Arial, Helvetica, sans-serif" size=2>CodeWarrior </FONT><FONT
size=2>也提供了一个适用于此处的库函数,这个库函数中的 </FONT><FONT
face="Arial, Helvetica, sans-serif" size=2>C </FONT><FONT size=2>控制台
</FONT><FONT face="Arial, Helvetica, sans-serif" size=2>I/O
</FONT><FONT
size=2>函数步不仅可以在程序显示完毕后锁定应用程序,而且还可以让你将输出的文本信息存储到一个文件中去。</FONT></P>
<P align=center>第一部分 <A
href="http://www.pdazone.com.cn/develop/CodeWarrior/lesson2_2.htm">第二部分</A><BR></P>
<HR>
<P>附原文:</P>
<P><B><B><FONT face="Arial, Helvetica, sans-serif" color=#000000
size=3>Displaying and Customizing Projects and
Targets</FONT></B></B></P><FONT face="Arial, Helvetica, sans-serif"
size=2>
<P>In this section of the lesson, I'll introduce you to the way
CodeWarrior handles files and give you a tour of the Project
window.</P>
<P><B><FONT size=+1>Understanding the Project File</FONT></B></P>
<P>To create programs in CodeWarrior, you will use a number of files
that work together to form a project. A project's settings and
pointers to other files are stored within a <B>project file.
</B>These settings include compiler and linker options, source
files, libraries, and information about how they interact with one
another to build the final product -- your program. For now, just
think of the project file as the brain of your project: it keeps
track of everything that is going on and knows how to combine files
and settings into a working application program. The Project window
in turn displays this information about your program and its files
and allows you to modify the project by just pointing and clicking.
Figure 2-1 shows the Project window.</P>
<TABLE cellSpacing=0 cellPadding=0 border=0>
<TBODY>
<TR>
<TD><IMG height=247
alt="Figure 2-1: Each project you create appears in the Project window. This one is empty."
src="显示和定制工程和目标文件(1).files/IcwwL2_fig1.gif" width=367
align=left> </TD></TR>
<TR>
<TD align=middle><FONT size=1><I>Figure 2-1: Each project you
create appears in the Project window. This one is
empty.</I></FONT> </TD></TR></TBODY></TABLE>
<P>Most of the files that make up your program are ordinary text
files. These files contain your source code. You'll create them by
typing the source code into the CodeWarrior editor. In some cases,
you will also use prebuilt source code and header files. There are
also library files, such as the Metrowerks Standard Library (MSL)
which provides valuable functions for math calculations and I/O
operations. </P>
<P>Your source code will usually be written in C or C++, but can
also be in any other language that is supported by a CodeWarrior IDE
plug-in. Recall that CodeWarrior is an extensible IDE. In other
words, by inserting (or writing) a plug-in, you can extend the
capabilities of the CodeWarrior IDE. For example, if someone
develops a new programming language, say Z++, you could create a
plug-in to support that language and sell it for a zillion bucks,
and then anyone using the CodeWarrior IDE could program in Z++.
Neat, huh?</P>
<P>Now that you understand how CodeWarrior uses files, let's take a
closer look at the Project window.</P>
<P><B><FONT size=+1>The Project Window</FONT></B></P>
<P>When you launch CodeWarrior and open or create a project, a
Project window greets you. To recap, it allows you to manage the
project, all of its files, and the <B>targets</B> that it builds. A
project contains all of the information necessary to build one or
more targets. A target is the file that CodeWarrior creates when you
build your program -- usually an application or library. Some
projects build multiple targets. For example, you may write a
program that has a DLL, as well as the main application that calls
it. In the CodeWarrior project, you can define one target to
generate the DLL, and another target to generate the application. In
this way, your project can build all the necessary targets, or
pieces, in one fell swoop. Figure 2-2 shows the Project window for a
program called Hello World.</P></FONT>
<DIV align=center>
<CENTER>
<TABLE cellSpacing=1 cellPadding=0 width="80%" border=0><FONT
face="Arial, Helvetica, sans-serif" size=2>
<TBODY>
<TR>
<TD width="100%">
<P align=center><IMG height=351
alt="Figure 2-2: The Project window for a program called Hello World lists all of the files that are included in the program or that are needed to build it."
src="显示和定制工程和目标文件(1).files/IcwwL2_fig2.gif" width=406
align=left></P></TD></TR></FONT>
<TR>
<TD width="100%"><FONT face="Arial, Helvetica, sans-serif"
size=2><FONT size=1><I>igure 2-2: The Project window for a
program called Hello World lists all of the files that are
included in the program or that are needed to build
it.</I></FONT> </FONT></TD></TR></TBODY></TABLE></CENTER></DIV>
<TABLE cellSpacing=0 cellPadding=0 border=0>
<TBODY></TBODY></TABLE>
<P><FONT size=1> </FONT></P><FONT
face="Arial, Helvetica, sans-serif" size=2>
<P>You can see that the Project window contains quite a few items.
At the top are three tabs: the Files tab (displayed in Figure 2-2),
the Link Order tab, and the Targets tab (both discussed later in
this lesson). Above the tabs is a pull-down menu that allows you to
choose which target to build. In this case, we have chosen the Debug
version of the Hello World project. The icons to the right of this
pull-down menu allow us to easily compile, link, and run the project
without having to use menu commands.</P>
<BLOCKQUOTE>
<P><B>Note:</B> The Link Order tab is called the Segments tab in
some versions of CodeWarrior. Some of you might have programmed
certain x86 processors using segmented code. This is not the case
with the Windows CodeWarrior tools. They generate x86 code that
uses a "flat," or unsegmented, memory space.</P></BLOCKQUOTE>
<P>As its name implies, the Files tab lists all of the files that
could possibly be used in the project. You can create groups
(represented by the folder icon) in the window to help manage the
files hierarchically and make it easier to keep track of which files
are being used. In our case, we place our C language source code
files (indicated by the .c extension) in a group called Sources.
We've organized libraries into other groups to keep things tidy.</P>
<P>The Sources group for our example holds the main.c file. Since we
have yet to build this project, the numbers in the Code and Data
columns are all set to zero. When we build the project for the first
time, these numbers will reflect the actual amount of code and data
the compiler creates when it translates the source code into machine
language. However, the library files ANSICX86.LIB and MWCRTL.LIB
have n/a next to them. This indicates that even though these files
are listed, they are not used as part of the Hello World target.
That's because these two libraries are used for non-debugging
development, which is not applicable for this target. If we were to
switch targets by picking the Release version of Hello World from
the menu, these columns would change to reflect the use of these
other libraries.</P>
<BLOCKQUOTE>
<P><B>Note</B> : The small bullet in the Target column to the
right of the Data column also indicates whether or not the file is
being used by the current target.</P></BLOCKQUOTE>
<P>Other columns in the main window include the Debug column, to the
right (see the little green bug?), which tells you whether this file
is currently set to generate debug information when it is compiled.
We will discuss this in more detail in Lesson 5. And lastly, the
pop-up menu at the far right of each row acts as a shortcut that
allows you to quickly open files and/or update sources for
compilation, open included header files, etc., depending on the type
of item it represents.</P>
<P>Let's build the Hello World project and see what the window looks
like after it is built. To build this project, select Make from the
Project menu. This will update all files that need to be built and
will produce the output file -- in this case, the Hello World
application.</P>
<TABLE cellSpacing=0 cellPadding=0 border=0>
<TBODY>
<TR>
<TD><IMG height=350
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -