Information Technology Reference
In-Depth Information
Using the Command Line Tool template
In a Cocoa application, main.c loads and runs the application, and you can ignore it. In a command-line applic-
ation, main.c is the application. As you might expect, the Command Line Tool template creates a C or C++ file
designed to run from the command line. Parameters are passed in argc and argv[] in the usual way. After
building, the tool runs in the Console window, which is introduced in Chapter 4. You also can run the tool from
Terminal.
As shown in Figure 3.11, you can select one of six templates for the tool. This is less flexible than it sounds. The
different variations link against the named OS X libraries. In practice, this means they differ only in the #in-
clude directive at the top of the file. For example, if you select the Core Foundation option, the template's
code looks like this:
#include <CoreFoundation/CoreFoundation.h>
int main (int argc, const char * argv[]) {
// insert code here...
CFShow(CFSTR(“Hello, World!\n”));
return 0;
}
FIGURE 3.11
Create a Command Line tool, a text-based application that doesn't use a GUI (Graphical User Interface). The
menu simply preselects different headers in a #include directive.
Search WWH ::




Custom Search