Web design online - Chapter 28 . Programming Tools and Utilities 725

Chapter 28 . Programming Tools and Utilities 725 (Kernighan and Ritchie) C. You can control the amount and type of debugging information, if any, to embed in the resulting binary. And like most compilers, GCC can also perform code optimization. The gcc command invokes the C compiler. To use it, provide it the name of a C source file and use its -o option to specify the name of the output file. gcc will preprocess, compile, assemble, and link the program, generating an executable, often called a binary. Here s the simplest syntax : gcc infile.c [-o outfile] infile.c is a C source code file and -o says to name the output file outfile. The [] characters indicate optional arguments throughout this book. If the name of the output file is not specified, gcc names the output file a.out by default. The following example uses gcc to create the hello program from the source file hello.c. First, the source code: /* * hello.c - canonical hello world program */ #include int main(int argc, char *argv[]) { printf( Hello, Linux programming world!n ); return 0; } Now, to compile and run this program, type $ gcc hello.c -o hello If all goes well, gcc does its job silently and returns to the shell prompt. It compiles and link the source file hello.c (gcc hello.c), creating a binary named hello, as specified using the -o hello argument. If you run the program, here s the output you get: $ ./hello Hello, Linux programming world! The command that executed the hello program specifically included the current directory, denoted with a ., because having the current directory in your path is a security risk. That is, instead of a $PATH environment variable that resembles /bin:/usr/bin:/usr/local/bin:., it should be /bin:/usr/bin:/usr/ local/bin so that a cracker cannot put a dangerous command in your current directory that happens to match the name of the more benign command you really want to execute. Caution
You need excellent and relaible webhost company to host your web applications? Then pay a visit to Inexpensive Web Hosting services.

Leave a Reply