home *** CD-ROM | disk | FTP | other *** search
INI File | 1991-06-22 | 16.7 KB | 321 lines |
- [INFORMATION ABOUT GNU C]
-
- This information is NOT intended to replace the official FSF manuals.
- When the FSF manuals and this file conflict, the FSF manuals are
- correct.
-
- [Arguments to the GCC call]
-
- df = default(ing), fn = function, xxxx = any text, nnnn = any number,
- var = variable. Note that gcc is case sensitive in its arguments.
-
- <OVERALL>
- xxxx.cc preprocess and compile and assemble and link this file
- xxxx.c preprocess and compile and assemble and link this file
- xxxx.i compile and assemble and link this file (do not preprocess it)
- xxxx.S preprocess and assemble and link this file (do not compile it)
- xxxx.s assemble and link this file (do not compile or preprocess it)
- xxxx.o link this file (do not assemble or preprocess or compile it)
- -v print commands and version numbers as they are executed
- -pipe compilation stages communicate by pipes, not by temporary files
- (-pipe does not work under DOS)
- -Bxxxx look for cpp & cc1 & as & ld first with prefix xxxx
- -bxxxx as -Bxxxx but before obeying -Bxxxx
- (Then, compiler uses prefix as in PATH environmental variable)
-
- <PREPROCESSING STAGE> (i.e. obeying the #directives)
- -E -oxxxx send preprocessed C to file xxxx, then stop
- -E send preprocessed C to standard output (= screen), then stop
- -C pass comments through, do not delete them. Error unless -E also
- -D xxxx=yyyy obey macro: #define xxxx yyyy
- -D xxxx obey macro: #define xxxx 1
- -d output list of #define's, not usual output. Error unless -E also
- -I xxxx for #include'd files, look first in directory xxxx:-
- (after or without -I-) for all #include'd files
- (before -I-) only for #include"file", not for #include<file>
- (after or before -I-) do not look first in current directory
- -I- see under -I xxxx
- -i xxxx preprocess file xxxx, keep macros defined in it, reject the rest
- -MM write a MAKE rule for how program is put together. Implies -E
- -M ditto, includung all #include'd files. Implies -E
- -nostdinc do not search standard dictionaries for #include'd files
- -P do not generate # lines with line number info
- -pedantic work exactly by ANSI
- -trigraphs process ANSI trigraphs (eg ??/ for \). Implied by -ansi
- -U xxxx do not predefine macro xxxx. Defeats -D
- -undef do not predefine any macros. Implied by -ansi
-
- <COMPILATION STAGE> (converts C code into assembler code)
- -S -oxxxx compile into assembler code onto file xxxx.S, then stop
- -S ditto, where xxxx = source file's name without its suffix
- -ansi ignore keywords asm, inline, typeof, and
- do not predefine macros unix, vax, etc that say which system;
- but still define them with __ attached at each end
- -traditional various feature of older C compilers, see below
- -O optimize
- -g produce debugging info
- -gg produce debugging info in an obsolete format
- -w no warning messages
- -W warn of:- (the first two only if optimizing)
- auto variable used before it is initialized
- auto variable not declared volatile, if longjmp may zap it
- function has both valued & valueless returns
- (falling off end = valueless return)
- statement is expression with no side effects
- -Wimplicit warn when function is implicitly declared
- -Wreturn-type warn if function defaults to int,
- and of return with no argument if function is not void
- -Wunused warn of vars and static fns and results which are not used
- -Wswitch warn of missing and out of range cases with switch(enum value)
- -Wcomment warn of /* in comment
- -Wtrigraphs warn of trigraphs
- -Wall as -W and all six abovementioned -Wxxxx arguments
- -Wshadow warn if local var has same name as another var
- -Wid-clash-nnnn warn if two names have first nnnn chars same
- -Wpointer-arith warn if sizeof(function or void): these are treated as 1
- -Wcast-qual warn if cast removes qualifier (e.g. const*int to *int)
- -Wwrite-strings give string literals the type const char[]
- -p insert code to write profile info for analysis program 'prof'
- -pg insert code to write profile info for analysis program 'gprof'
- -a insert code to write profile info for basic blocks
- -m68020 output for 68030, not 6800. Default.
- -mc68020 output for 68030, not 6800. Default.
- -m68000 output for 68000, not 68020
- -mc68000 output for 68000, not 68020
- -m68881 output 68881 instructions for floating point. Default
- -mshort int (rather than long int or short int) will be 16 bits wide
- -mnobitfield no bit fields. implied by -m68000
- -mbitfield bit fields. default. implied by -m68020
- -mrtd use a different way to call functions
- -fxxxx: prefix or remove 'no-' after '-f' to reverse its effect.
- In each -fxxxx and -fno-xxxx pair, the omitted form is default.
- -fpcc-struct-return return struct and union values as in system's usual C
- -ffloat-store do not store float values in registers
- -fno-asm do not recognise keywords asm, inline, typeof
- -fno-defer-pop pop function args at once after each function return
- -fstrength-reduce some loop optimizations
- -fcombine-regs combine register-to-register copy instructions
- -fforce-mem copy memory values into registers before arithmetic
- -fforce-addr copy address values into registers before arithmetic
- -fomit-frame-pointer don't keep frame pointer in register if not needed
- -finline-functions all 'simple' functions are compiled inline.
- The compiler decides if each function is simple enough
- -fcaller-saves allocate values in registers zapped by function calls
- -fkeep-inline-functions output a separate version of all inline functions
- -fwritable-strings store strings in writable data segment, not unique
- -found-mismatch allow x?y:z with y & z mismatched types. Result is void
- -fno-function-cse do not put function addresses in registers
- -fvolatile all memory refs through pointers are treated as volatile
- -fshared-data data and non-const vars are shared data, not private
- -funsigned-char char = unsigned char
- -fsigned-char char = signed char (default)
- -fdelayed-branch re not wasting instruction spaces after jumps
- -ffixed-xxxx generate code so it won't alter register xxxx
- -fcall-used-xxxx let function calls zap register xxxx
- -fcall-saved-xxxx don't let function calls zap register xxxx
- -pedantic allow only what is legal by ANSI definition
- -Q output function names, time taken by compiler stages, etc
- -dumpbase xxxx specify first part of dump file names for -d<letter>
- (Warning: default = whole input file name including its suffix,
- which on PC's will cause illegal names for dump files.)
- -d<letter> make RTL intermediate language dump after:-
- <step that dump is made after> <file that dump is written to>
- -dr converting program to RTL xxxx.RTL
- -dj first jump optimization xxxx.JUMP
- -ds finding common subexpressions xxxx.CSE
- -dL loop optimization xxxx.LOOP
- -df flow analysis xxxx.FLOW
- -dc instruction combination xxxx.COMBINE
- -dl local register allocation xxxx.LREG
- -dg global register allocation xxxx.GREG
- -dJ last jump optimization xxxx.JUMP2
- -dd delayed branch scheduling xxxx.DBR
- where xxxx = as stated by -dumpbase.
-
- <ASSEMBLY STAGE> (turning assembler code into object code)
- -c -oxxxx compile into object code onto file xxxx.O, then stop
- -c ditto, where xxxx = source file's name without its suffix
-
- <LINKING STAGE> (turning object code files into executable file)
- -lxxxx look in system directories for library xxxx.A
- -Lxxxx also look in directory xxxx for libraries
- -nostdlib do not look in standard system libraries
- ----------------------------------------------------------------------
- [Effects of -traditional]:-
-
- All extern declarations are global even if inside a function.
- typeof, inline, signed, const, volatile are not recognized (but asm is).
- Pointers can be compared with integers.
- unsigned short and unsigned char promote to unsigned int.
- Out of range floating point literal is not an error.
- Strings are all stored separately and can be written to.
- longjmp preserves all auto variables (other than register variables)
- Preprocessor converts comments to nothing, not to space.
- Looks for macro arguments inside strings in macro definition.
- Newline in string (literal newline, not \n) ends the string.
- __STDC__ is not predefined.
- ----------------------------------------------------------------------
- [Features of the new ANSI standard for C]
-
- \v in string and char constants means vertical tabulate (ctrl-K)
- \a in string and char constants means beep alias bell (ctrl-G)
- If you want two question marks together in a string, write them as ?\? to
- avoid confusion with a trigraph, if you compile in trigraph mode.
- New standard macros: __DATE__ __TIME__ __FILE__ __LINE__ __STDC__
- New declaration qualifiers:-
- const this variable must not be written to.
- volatile the system may change this variable without warning.
- signed opposite to unsigned.
- U or u appended to constants means 'unsigned'.
- Other new keywords:-
- enum e.g. enum color {red,blue,green,yellow} to declare
- an enumerated type like in Pascal.
- void (1) in function declaration: it returns no type.
- (2) in cast (void) ignore value.
- (3) in function declaration, e.g. int calc(void);
- function takes no parameters.
- (4) type void* general pointer to any value
- Old =- etc is no longer an operator, but is treated as = and -
- &x is now legal even if x is an array or a function.
- Unary + is legal.
- Two new operators allowed only in macro definitions:-
- # before use of macro argument insert stringified copy of call argument
- ## the matter before and after ## is concatenated
- Pointer void* can be cast to any pointer type and vice versa
- No implicit conversion between different pointer types; you must use a cast.
- (pointers to functions with different parameter patterns, are different types)
- Function pointer can't be converted to or from non-function pointer.
- No macro substitution inside strings.
- Strings with nothing between but spaces/newlines/comments are concatenated.
- (NB: e.g. "miaow""miaow" means "miaowmiaow"; the internal "" is <not> a quote-
- image as in Algol68; the C 'quote image' is \" )
- (Hexadecimal characters (e.g. \xff)) don't extend across concatenation.)
- Writing to string constants is illegal, unless you use '-traditional'.
- Functions should be declared with prototypes.
- Function parameters are passed as they are declared.
- 'long float' is illegal. Use 'double' instead.
- Expression in switch( ) can be any integral type, not only int.
- Structures & unions can be used without restriction as function result types.
- Functions can be used as initializers.
- Calling a pointer-to-function as if it was a function, is allowed.
- (*x) where x is a function, is allowed and means the same as x.
- ----------------------------------------------------------------------
- [Libraries]
-
- <library> <declares>
- <assert.h> assert(xxxx) /* abort program if condition xxxx is false */
- <ctype.h> char testing and conversion functions.
- isascii(), although this is not now standard C
- <errno.h> error handling functions
- <float.h> information about types float, double, long double
- <limits.h> information about integral types etc
- <locale.h> controlling decimal point character, currency character,
- collation order. (Not yet present.)
- <math.h> mathematical functions that take and return double values.
- You must compile with -lm to get the maths library.
- <setjmp.h> type jmp_buf, macro setjmp, function longjmp.
- <signal.h> macros and types re signal handling.
- <stdarg.h> macros to advance through function parameters. Example of use:-
- void calc(int nargs,...) {
- va_list xx; /* you must declare a local variable of this type */
- va_start(xx,nargs) /* xx now points to parameter nargs */
- va_arg(xx,yyy) /* move xx to point to next parameter, which must
- be of type yyy (where yyy is some type) (or effect
- unpredictable). Returns the value of that parameter. */
- va_end(xx) /* end the parameter lookup tidily */
- <stddef.h> various standard types and macros such as NULL.
- offsetof() /* find offset of a member within its structure */
- <stdio.h> type FILE and many input & output macros & types & functions
- <stdlib.h> miscellaneous, many system-dependent.
- <string.h> string handling and memory accessing functions.
- <time.h> types and functions re the time.
- ----------------------------------------------------------------------
- [Differences betwen Gnu C and many non-ANSI C's]
-
- Most of these differences are removed by compiling with '-traditional'.
-
- String constants are read only. Treats identical strings as the same string.
- So, string constant can't be used as argument of mktemp, and of scanf and
- fscanf and sscanf when they use their format argument as scratch paper
- Macro arguments are not substituted inside strings.
- Automatic allocation of variables to registers. So, setjmp and longjmp may zap
- any auto variable not declared volatile. To stop a variable from being put in
- a register, calculate its address somewhere.
- extern declarations within a function only apply within that function.
- Unterminated character constants cause fault in text skipped by preprocessor
- conditionals. Always put /* */ around comments!
- In functions that return float, the float is not converted to double.
- ==== This difference can be removed by compiling with -fpcc-struct-return:-
- In functions that return struct or union values:-
- Other C compilers return the address of static storage where the value is.
- if sizeof(value) == 1 or 2 or 4 or 8, Gnu C function returns value as scalar
- else Gnu C function stores value at address supplied by caller of function.
- ==== These differences can't be removed:-
- 'long', 'short', etc can't be followed by a type name declared by typedef.
- A type name declared by typedef can't be used as a function parameter.
- Operators += -= *= etc can't have a space inside them.
- On the Sparc, struct and union arguments of functions are passed:-
- by other C compilers as their addresses, as if by reference.
- by Gnu C by copying their vales into the parameter list.
- ----------------------------------------------------------------------
- [Gnu C features not in ANSI]
-
- <expression> ::= ( { <statements and declarations> } )
- obeys the enclosed compound statement, then keeps the value of its last
- component statement.
- This is not allowed where an expression must be constant.
- <declaration> ::= typedef <name> = <expression>;
- declares the name as a typename for whatever type the expression is.
- <type_definition> ::= typeof ( <expression> )
- means whatever type the expression is.
- <type_definition> ::= typeof ( <type_definition> )
- means the type of the inner type definition. On occasions it can serve
- as an aid to clarity by its bracketing effect.
- <lvalue> ::= <compound expression>
- if its last component is a lvalue, e.g. (a,b,c) = 4;
- <lvalue> ::= <conditional expression>
- if all of its alternatives are lvalues. e.g. (a?b:c) = 5;
- <lvalue> ::= <cast>
- if the expression in the cast is a lvalue. It is obeyed thus:-
- after &, e.g. & ( int * ) x
- value = address of x, of type int *
- before =, e.g. (int) x = 5.5;
- convert 5.5 to int, then to type of x, then copy it into x
- before += -= *= etc, e.g. (int) x += 5.5;
- convert value of x to int; convert 5.5 to int; obey += with
- those values; convert result to type of x; copy it into x.
- <expression> ::= <expression> ? : <expression>
- e.g. x ? : z means x ? x : z , except that x is not recalculated.
- Declared array with length zero
- useful as last element of struct which is intended as a header for a
- variable-length object set up by e.g. malloc()
- Declared array whose bound is not constant
- The array is set up at run time and deleted at block exit.
- Function declaration parameter is array whose bound is present & not constant
- Here you tell the system the bounds of the array. As in Fortran, if you
- tell lies about what the bounds are, the effect is unpredictable.
- Array value which is not an lvalue, can have subscripts.
- sizeof(void) means 1; sizeof(<function type>) means 1
- Arithmetic is allowed on void* and pointer to function values.
- If <constructable> ::= <array type or struct type or union type definition>:-
- In <constructable> <name> = { <list of values> };
- the values can be non-constants if the declaration is auto.
- <expression> ::= ( ( <constructable> ) { <list of values> } )
- is a 'constructor expression'. A value of the type stated is set up.
- volatile as qualifier for function declaration
- tells the compiler that the function will never return.
- const as qualifier for function declaration
- tells the compiler that the function has no side effects and examines
- nothing except its arguments.
- The character '$' can be used in names.
- __alignof__( <type> )
- = alignment (recommended or compulsory) of that type
- inline as qualifier for function declaration
- means that that function is copied in in full instead of being called,
- where the source form calls it.
- asm( )
- assembler instructions in C program
-
-
-
-