ARM Technical Support Knowledge Articles

MISSING TYPE-SPECIFIER DOES NOT GENERATE ERROR

Applies to: General Topics

Answer


Information in this article applies to:


SYMPTOMS

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?

CAUSE

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.

MORE INFORMATION

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

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential