|ARM Technical Support Knowledge Articles|
Applies to: General Topics
Information in this article applies to:
I have declared some global variables as follows:
char var0 = 0; var1 = 1, var2 = 2, var3 = 3;
I typed a semicolon instead of a comma by mistake. The compiler did not generate an error and the variables were incorrectly initialized. Why?
By inserting a semicolon you have split your single variable declaration into two. The second being:
var1 = 1, var2 = 2, var3 = 3;
Because there is no type-specifer such as char then int is assumed. The variables are initialized correctly, but as ints.
Refer to section A8.2 Type Specifiers in The C Programming Language by Brian Kernighan and Dennis Ritchie.
Article last edited on: 2005-07-19 10:24:16
Did you find this article helpful? Yes No
How can we improve this article?