nfoTools | tools>t060101>d | index.html 0.0.5 2023-06-25 |
---|---|---|
Work in Progress |
The overall objective is to convert single-file program, hello.c
,
into a program, hello.exe
, that can be run directly on the computer. There
is a simple pattern using the
command-line interface
that is initiated along with the
Developer Command Prompt’s
initialization of a build tools environment.
The diagrammatic view, below, parallels the observed command-line operation in
Getting to “Hello”. This is a
general pattern, using the specific example of hello.c
for clarity.
Two command-line operations are performed.
>CL hello.c
hello.c
into the program file
hello.exe
without error>hello
hello.exe
, providing its output directly in the
command-line interfaceKEY IDEA hello.exe
is repeatedly-usable, while having
to be compiled only once. The program can be used by others without building
it or even knowing how.
With the simple “>CL hello.c
” command, The hello.exe
program is
automatically produced as a Command-Line Application (CLA). This is the
default behavior in the absence of any additional parameters in the command.
The resulting program is completely self-contained and structured for
operation by command prompt.
EXPERIMENT. From the File Explorer, double-click on the hello.exe
entry. A command-line interface will open automatically, the program will
run, and the command-line interface will exit. That can happen so rapidly
that it might not be observed at all, as if nothing happened.
For now, simply open a command prompt first. Then operate the program with a command. Later, there will be ways to have operation be accomplished more directly and smoothly.
The Build Tools program, CL/exe
operates as a precision multi-tool. It has
many options and stages of operation. With the simple command-line for
“Getting to Hello,” much happens visibly and also under the covers.
An automatic pattern is separation of compiling into two stages: compile and
then link. The compile stage converts the source code to a file consisting
of (linkable) machine code for that source. The link stage combines modules
of such code from many sources, including Standard C libraries, into a single
executable, such as hello.exe
. The general idea is reflected in the
simplified diagram.
hello.c
and, when there are no errors,
derives an “object code” file, hello.obj
for subsequent use.
#include <stdio.h>
causes the file stdio.h
to be retrieved and blended
into hello.c
as if it is part of hello.c
.stdio.h
file is called a “header” because of this usage. The file
is found among such includable headers in the Software Development Kit (SDK)
reachable via the Build Tools Environment. All of the Standard C Language
library facilities are accessed via use of headers in this manner.stdio.h
does not provide implementations of the Standard C Library in
this pattern. Instead, stdio.h
provides definitions of a collection of interfaces and some data
by which a program can correctly refer to implementations of those facilities
in library files supplied elsewhere in the SDK.stdio.h
has some #include
operations
in its own file, and this nested process is continued until all the implicit
definitions are pulled into the hello.c
compilation.hello.obj
is the machine-language code (in “object” file format) that is
derived from hello.c
, stdio.h
, and other settings of CL. hello.obj
is
decorated with information about how the code can be combined as a module
with other code.
hello.obj
code named main
hello.obj
to code expected from elsewhere
including an entry named fputs
(and stdout
, in effect).hello.exe
program.
main
to be satisfied elsewhere. That reference
is satisfied by hello.obj
in this case.fputs
from hello.obj
is resolved in the SDK collection of C runtime library
modules.Discussion about nfoTools is welcome at the Discussion section. Improvements and removal of defects in this particular documentation can be reported and addressed in the Issues section. There are also relevant projects from time to time.