provides
readable alternatives to certain operators or punctuators.
``The ANSI C Standard'' is the common name for
ANSI X3.159-1989, American National Standard for Information Systems
- Programming Language - C
.
filename extensions .c .c++ .C .cc .cxx .cpp .h .H .hh
comments and administrative information
human-readable text in sourcecode
students look for illuminating comments
in source code and human-readable strings in the sourcecode
``If you'd like to know more about writing programs in C,
you can't do much better than reading
_The C Programming Language (Second Edition)_ by Brian W. Kernighan
and Dennis M. Richie.
For those of you who wish to voyage a little further,
_Reusable Data Structures for C_ by Roger Sessions
is well worth perusing.''
-- recc. Clive ``Max'' Maxfield http://www.maxmon.com/
in _Bebop to the Boolean Boogie_ p. 331.
General rule for end-squiggly-brackets (``@}'') and semicolons(``;''):
The end-squiggly-bracket at the end of a @var{function} is special.
Never put a semicolon after it.
The end-squiggly-bracket at the end of a do@{@}while(). is special.
Never put a semicolon after it.
Always put semicolons after all other end-squiggly brackets.
A top-down view
``filter''
``sponge''
``interactive''
@node Concept Index, , data type index, Top
@unnumbered Concept Index
@comment node-name, next, previous, up
@printindex cp
@summarycontents
@contents
@comment end c_reference_manual.texinfo, maintained by David Cary
@bye
@ignore
.texinfo snippets
Only visible in source file !
@chapter
@section
@subsection
Write a command such as @noindent at the beginning of a line as the
only text on the line.
(@noindent prevents the beginning of the next line from being indented
as the beginning of a paragraph.)
@iftex
Only visible in TeX typesetting !
@end iftex
@ifinfo
Only visible in the Info file !
@end ifinfo
@c Only visible in source file !
@comment Only visible in source file !
What is the difference between
@code{void}
vs.
@samp{void}
?
@itemize @bullet
@item
@item
@end itemize
@enumerate
@item
@item
@item
@end enumerate
...
ellipses
@dots{}
warning:
if you use fread() to read from a file,
and you ask it to read *all* the remaining
data in the file, feof() returns false (!),
even though there is no more data in the file to be read.
Only after fread() tries to read *beyond*
the end of the file does feof() return true.
-- Paul
functions have inputs and outputs.
[needs example]
Since C is pass-by-value,
obviously any "int" or "double" you call a function with
must be a *input* to that function.
The return value of a function is one of its outputs.
Often a single output is inadequate, one wants to return more stuff -- then what ?
use & in call, * in function definition ... to tell the function where to put its outputs.
...
One more idiom:
Sometimes people use const ... * for some *inputs* to a function
(typically items that are large structures and arrays),
since passing a pointer is much faster than
copying the entire item. The const indicates that
this is really a input to the function, and forbids the function from changing it.
[FIXME:]
Ghostscript uses ANSI syntax for function definitions.
Because of this,
when compiling with cc, it must preprocess each .c file to convert it
to
the older syntax defined in Kernighan and Ritchie, which is what most
current Unix compilers (other than gcc) support.
This step is automatically performed by a utility called ansi2knr,
which is included in
the Ghostscript distribution.
The makefile automatically builds ansi2knr.
-- from make.txt, which you get with a Ghostscript installation.
[Should I mention the URI link to the "GNU Ghostscript" version of
ansi2knr ?]
If you write ANSI C programs,
http://iel.ucdavis.edu/CH/
they can be interpreted in the CH environment.
The November, 1997 Draft Specification for C98
http://plg.uwaterloo.ca/~cforall/C9X/
information on "Makefile Basics"
http://www.gnu.org/prep/standards_41.html
variables not local to a function:
static: local to this module (file) (notice that this word mean something completely when modifying a variable local to a function)
extern
global.
the April 28, 1995
Working Paper of ISO Working Group WG21
ftp://research.att.com/dist/c++std/WP/CD1/
lots of info on the C programming language
http://www.lysator.liu.se/c/
Doug Gwyn's
http://www.lysator.liu.se/c/iso646.h
ansi2knr - Convert ANSI C programs to traditional ("Kernighan & Richie") C.
is available via
http://www.cs.wisc.edu/~ghost/
as
ftp://ftp.cs.wisc.edu/ghost/ansi2knr.c
char* something; // Nothing is const.
const char* something; // content is const.
char* const something; // pointer is const.
const char* const something; // Everything is const.
Obviously, as the pointer itself is just a variable,
it makes no sense to require it being const.
Thus protecting the content pointed to is sufficient.
--
http://www.gamers.org/dEngine/r3D/coding.html
[DAV: huh ? shouldn't the const come _before_ the "*" ?]
stick with GNU getopt/getopt_long. This parses arguments in a manner
compatible with the GNU coding standards and compatibily with Unix.
Additionally it is very simple to use.
or use argp
http://www.gnome.org/devel/start/argp.shtml
Joe maintains the FAQ list for the GNU C++ compiler.
http://www.synopsys.com/news/pubs/research/people/jbuck.html
http://egcs.cygnus.com
"egcs is an experimental step in the development of GCC, the GNU C compiler."
comp.lang.c Hypertext C-FAQ
http://www.eskimo.com/~scs/C-faq/top.html
"GNU Coding Standards"
http://www.gnu.ai.mit.edu/prep/standards_toc.html
by Richard Stallman
Programming in C
http://www.lysator.liu.se/c/
lots of info about the ANSI C standards,
a public-domain version of "#include ",
tutorials,
reviews of books on C,
detailed technical comments,
I kind of like the
http://www.lysator.liu.se/c/pikestyle.html
to which it points. (Like me, he prefers lowercase).
Simple rule: include files should never include include files.
[--
Rob Pike
http://www.lysator.liu.se/c/pikestyle.html
]
_The CWEB System of Structured Documentation_ book by Donald E. Knuth
http://sunburn.stanford.edu/~knuth/cweb.html
"CWEB is a version of WEB for documenting C, C++, and Java programs.
...
Thus CWEB combines TeX with today's most widely used professional programming languages."
http://www.vendian.org/mncharity/ccode/grammar/
http://www.vendian.org/mncharity/ccode/
Some html-ized C language grammars
Some PERL regular expressions for preprocessor-level parsing of C source code.
A sloppy diff between ANSI and C9X grammars.
The Motor Industry Research Association,
the MISRA Consortium.
http://www.misra.org.uk/
sells
"Guidelines for the Use of the C Language in Vehicle Based Software" for £35 / copy.
Has some other
"Development Guidelines for Vehicle
Based Software"
that are available for download.
"(MISRA C is also called "Safer C")"
Simple Vector Library
by Andrew Willmott
http://pecan.srv.cs.cmu.edu/afs/cs/user/ph/www/859E/src/svl/doc/svl.html
http://pecan.srv.cs.cmu.edu/afs/cs/user/ph/www/859E/src/svl/
SVL vector & matrix package
SVL provides 2-, 3- and 4-vector and matrix types, as well as
arbitrarily-sized vectors and matrices, and various useful functions
and arithmetic operators.
in C++.
arg_parse(3)
by Paul Heckbert
http://pecan.srv.cs.cmu.edu/afs/cs/user/ph/www/859E/src/libarg/arg_parse.text
http://www.cs.cmu.edu/afs/cs/user/ph/www/859E/src/libarg/
"source code to an argument parser with lots of nifty features.
It's written in ANSI C, but it should link with C++ code with no trouble."
"It is hoped that use of arg_parse will help standardize
argument conventions and reduce the tedium of adding options
to programs."
@end ignore