top/contents search

11. ANSI/ISO Standard C

11.1 What is the ``ANSI C Standard?''

11.2 How can I get a copy of the Standard?

11.2b Where can I get information about updates to the Standard?

11.3 My ANSI compiler complains about a mismatch when it sees

	extern int func(float);

	int func(x)
	float x;
	{ ...

11.4 Can you mix old-style and new-style function syntax?

11.5 Why does the declaration

extern int f(struct x *p);
give me an obscure warning message about ``struct x declared inside parameter list''?

11.6 I had a frustrating problem which turned out to be caused by the line

	printf("%d", n);
where n was actually a long int. I thought that ANSI function prototypes were supposed to guard against argument type mismatches like this.

11.7 I heard that you have to #include <stdio.h> before calling printf. Why?

11.8 I don't understand why I can't use const values in initializers and array dimensions, as in

	const int n = 5;
	int a[n];

11.8b If you can't modify string literals, why aren't they defined as being arrays of const characters?

11.9 What's the difference between const char *p, char const *p, and char * const p?

11.10 Why can't I pass a char ** to a function which expects a const char **?

11.11 I've got the declarations

	typedef char *charp;
	const charp p;
Why is p turning out const, instead of the characters pointed to?

11.11b What's the difference between

	const MAXSIZE = 100;
	#define MAXSIZE 100

11.12a What's the correct declaration of main()?

11.12b Can I declare main as void, to shut off these annoying ``main returns no value'' messages?

11.13 But what about main's third argument, envp?

11.14a I believe that declaring void main() can't fail, since I'm calling exit instead of returning, and anyway my operating system ignores a program's exit/return status.

11.14b So what could go wrong? Are there really any systems where void main() doesn't work?

11.15 The book I've been using, C Programing for the Compleat Idiot, always uses void main().

11.16 Is exit(status) truly equivalent to returning the same status from main?

11.17 I'm trying to use the ANSI ``stringizing'' preprocessing operator `#' to insert the value of a symbolic constant into a message, but it keeps stringizing the macro's name rather than its value.

11.18 What does the message ``warning: macro replacement within a string literal'' mean?

11.19 I'm getting strange syntax errors inside lines I've #ifdeffed out.

11.20 What are #pragmas and what are they good for?

11.21 What does ``#pragma once'' mean? I found it in some header files.

11.22 Is char a[3] = "abc"; legal? What does it mean?

11.23 Since array references decay into pointers, if arr is an array, what's the difference between arr and &arr?

11.24 Why can't I perform arithmetic on a void * pointer?

11.25 What's the difference between memcpy and memmove?

11.26 What should malloc(0) do? Return a null pointer or a pointer to 0 bytes?

11.27 Why does the ANSI Standard place limits on the length and case-significance of external identifiers?

11.28 What was noalias and what ever happened to it?

11.29a My compiler is rejecting the simplest possible test programs, with all kinds of syntax errors. It's complaining about the first line of

	main(int argc, char **argv)
		return 0;

11.29b What does the message ``Automatic aggregate intialization is an ANSI feature'' mean? My compiler is complaining about valid ANSI code.

11.30 Why are some ANSI/ISO Standard library functions showing up as undefined, even though I've got an ANSI compiler?

11.31 Does anyone have a tool for converting old-style C programs to ANSI C, or vice versa, or for automatically generating prototypes?

11.32 Why won't the Frobozz Magic C Compiler, which claims to be ANSI compliant, accept this code? I know that the code is ANSI, because gcc accepts it.

11.33 People seem to make a point of distinguishing between implementation-defined, unspecified, and undefined behavior. What do these mean?

11.33b What does it really mean for a program to be ``legal'' or ``valid'' or ``conforming''?

11.34 I'm appalled that the ANSI Standard leaves so many issues undefined. Isn't a Standard's whole job to standardize these things?

11.35 People keep saying that the behavior of i = i++ is undefined, but I just tried it on an ANSI-conforming compiler, and got the results I expected.


contents search
about this FAQ list   about eskimo   search   feedback   copyright

Hosted by Eskimo North