Questions tagged [c89]

This tag is for questions regarding the international standard ISO 9899:1990, also known as "C89", "C90" or "ANSI C", with amendments and technical corrigenda (as opposed to K&R C, C99, C11 or later C standard revisions).

The first C standard was released 1989 nationally in USA, by their national standard institute ANSI. This release is called C89 or ANSI-C. One year later, the American standard was accepted internationally and published by ISO (ISO 9899:1990). This release is called C90. Technically, it is the same standard as C89/ANSI-C, though formally, C90 replaced C89/ANSI-C, making them obsolete.

Always use the tag for all your C questions, then complement it with the tag for questions that are specific to this version of the standard.

643 questions
20
votes
8 answers

Which version of C is more appropriate for students to learn- C89/90 or C99?

I'm looking into learning C basics and syntax before beginning Systems Programming next month. When doing some reading, I came across the C89/99 standards. According to Wikipedia, C99 introduced several new features, including inline…
Jason
  • 11,263
  • 21
  • 87
  • 181
20
votes
2 answers

Does either ANSI C or ISO C specify what -5 % 10 should be?

I seem to remember that ANSI C didn't specify what value should be returned when either operand of a modulo operator is negative (just that it should be consistent). Did it get specified later, or was it always specified and I am remembering…
Chas. Owens
  • 64,182
  • 22
  • 135
  • 226
20
votes
4 answers

Rationale for 509 minimum character limit

I've seen a lot of the minimal requirements that an ANSI C compiler must support like 31 arguments to a function, and most of the numbers seem to make some kind of sense. However, I cannot see the reasoning for supporting at least 509 characters in…
Ryan Haining
  • 35,360
  • 15
  • 114
  • 174
20
votes
6 answers

K&R Exercise 1.16 - Limitation on line length

I'm learning C from K&R's "The C Programming Language" book. I'm doing the exercises specified in the book. I'm on exercise number 1.16, but I don't understand it. Exercise 1.16: Revise the main routine of the longest-line program so it will …
Andrey Bushman
  • 11,712
  • 17
  • 87
  • 182
20
votes
4 answers

Should I use ANSI C (C89)?

It's 2012. I'm writing some code in C. Should I be still be using C89? Are there still compilers that do not support C99? I don't mind using /* */ instead of //. I'm not sure about C89 forbids mixing declarations and code. I'm kind of leaning…
mk12
  • 25,873
  • 32
  • 98
  • 137
19
votes
2 answers

Valid programs in C89, but not in C99

Are there features / semantics introduced, or removed, in C99 which would make a well defined program written in C89 either invalid (i.e not compiling anymore, according to the C99 standard) compiling, but having different semantics. My findings…
Leandros
  • 16,805
  • 9
  • 69
  • 108
19
votes
4 answers

Why can't I "goto default;" or "goto case x;" within a switch selection structure?

Section 6.8.1 of C11 or C99, or section 3.6.1 of C89 all seem to indicate that default and case x (where x is some constant-expression) are examples of labeled statements, along-side identifier:-style labels that are suitable for use with goto. I'm…
autistic
  • 1
  • 3
  • 35
  • 80
19
votes
1 answer

Why do some C standard headers begin with 'std' while others don't?

For example, in the new C11 standard there have been added stdalign.h and threads.h. Why not stdthreads.h or align.h? Is it to avoid collisions with existing libraries and system headers?
szx
  • 6,433
  • 6
  • 46
  • 67
18
votes
4 answers

Why can't gcc find the random() interface when -std=c99 is set?

I do "#include " at the top of the source. Example compilation: /usr/bin/colorgcc -std=c99 -fgnu89-inline -g -Wall -I/usr/include -I./ -I../ -I../../ -I../../../ -I../../../../ -O3 -o f8 f8.c In file included from f8.c:7: ctype-cmp.c:…
Setjmp
  • 27,279
  • 27
  • 74
  • 92
18
votes
6 answers

Forward declare FILE *

How do I forward declare FILE * in C? I normally do this using struct MyType;, but naturally this doesn't appear to be possible. If behaviour differs between C standards or compilers and with C++, this is also of interest. Update0 Why I want to do…
Matt Joiner
  • 112,946
  • 110
  • 377
  • 526
18
votes
7 answers

What C99 features are considered harmful or unsupported

I usually write C code in C89, now some features of C99 (like intxx_t or __VA_ARGS__ or snprintf) are very useful, and can be even vital. Before I more my requirements from C89 to C99 I wanted to know which of C99 features were widely supported and…
Nicolas Goy
17
votes
4 answers

Compatibility of C89/C90, C99 and C11

I just read: C Wikipedia entry. As far as I know there are 3 different versions of C that are widely used: C89, C99 and C11. My question concerns the compatibility of source code of different versions. Suppose I am going to write a program (in C11…
Michael S
  • 466
  • 1
  • 4
  • 12
17
votes
3 answers

Is the %zu specifier required for printf?

We are using C89 on an embedded platform. I attempted to print out a size_t, but it did not work: #include int main(void) { size_t n = 123; printf("%zu\n",n); return 0; } Instead of 123, I got zu. Other specifiers work…
Trevor Hickey
  • 36,288
  • 32
  • 162
  • 271
17
votes
2 answers

C - Why did ANSI only specify six characters for the minimum number of significant characters in an external identifier?

I have a question regarding section 5.2.4.1 Translation Limits in the first American National Standard for Programming languages - C, also known as ANSI/ISO 9899-1990, ISO/IEC 9899.1990 (E), C89, etc. Simply put, the first ANSI C standard. What does…
pipe
  • 657
  • 10
  • 27
17
votes
2 answers

Is it legal and well defined behavior to use a union for conversion between two structs with a common initial sequence (see example)?

I have an API with a publicly facing struct A and an internal struct B and need to be able to convert a struct B into a struct A. Is the following code legal and well defined behavior in C99 (and VS 2010/C89) and C++03/C++11? If it is, please…
Coder
  • 441
  • 2
  • 17
1 2
3
42 43