C Flashcards
(40 cards)
What are C programs are compiled into?
Object code.
What is gcc?
The GNU Compiler Collection is an open source C compiler.
What is the default executable name produced by gcc?
a.out
How can you specify the executable name produced by gcc?
Using the -o switch.
What does cpp stand for?
cpp is the C preprocessor.
When does cpp examine source code, relative to compilation?
Source code is examined by cpp prior to compilation.
cpp must be called separately from gcc.
False, gcc calls cpp automatically.
What does the following line do?
cpp hello.c
By default, independent invocations of cpp prints the rewritten source code to the screen.
How are cpp directives distinguished from regular C code?
A leading # symbol.
Macros are pure textual substitutions, typically used for defining what 2 things?
Constants, and very simple functions in compact form.
What would occur if gcc encountered a #include directive?
It would produce an invalid error syntax.
In what way are standard header files included differently than user defined header files?
Using <file>, instead of “path”.
Why is no additional path information included with standard header file names?
Because these are located in pre-defined folders that cpp and the compiler will always search.
Can operating systems or platforms define their own standard header files?
Yes.
What about the C compilation process makes header files necessary?
C compilation is a line by line process that will generate errors if a not previously defined identifier is encountered.
Source files are compiled interdependently.
False, they are compiled independently, which further reinforces the need for header files.
Which compiler error is commonly associated with the omission of a header file?
“Symbol could not be resolved.”
The C library is big, relative to other languages.
False.
%i can be used in place of %d to specify an integer.
True.
Which format specifier is used for pointers?
%p
What should be used in place of printf() for displaying error/warnings?
fprintf(stderr, message, var_list);
Why should fprintf() be used in place of printf() for displaying errors?
Because fprintf() allows specification of output stream, and stderr is unbuffered (usually prints immediately).
NULL is a keyword in C.
False - NULL is a macro defined in several standard C headers.
How can NULL be defined as a macro?
#define NULL ((void *)0)