Section 54.1: Duplicate variable names in the same scope
An example of a constraint as expressed in the C standard is having two variables of the same name declared in a scope1), for example:
void foo(int bar)
{
int var;
double var;
}
This code breaches the constraint and must produce a diagnostic message at compile time. This is very useful as compared to undeļ¬ned behavior as the developer will be informed of the issue before the program is run, potentially doing anything.
Constraints thus tend to be errors which are easily detectable at compile time such as this, issues which result in undeļ¬ned behavior but would be diļ¬cult or impossible to detect at compile time are thus not constraints.
- exact wording:
Version = C99
If an identiļ¬er has no linkage, there shall be no more than one declaration of the identiļ¬er (in a declarator or type speciļ¬er) with the same scope and in the same name space, except for tags as speciļ¬ed in 6.7.2.3.
Section 54.2: Unary arithmetic operators
The unary + and – operators are only usable on arithmetic types, therefore if for example one tries to use them on a struct the program will produce a diagnostic eg:
struct foo
{
bool bar;
};
void baz(void)
{
struct foo testStruct;
-testStruct; /* This breaks the constraint so must produce a diagnostic */
}
About us and this blog
We are a digital marketing company with a focus on helping our customers achieve great results across several key areas.
Request a free quote
We offer professional SEO services that help websites increase their organic search score drastically in order to compete for the highest rankings even when it comes to highly competitive keywords.
Subscribe to our newsletter!
More from our blog
See all postsRecent Posts
- Chapter120:YieldKeyword 20/05/2024
- Chapter119:LockStatement 19/05/2024
- Chapter118:Makingavariablethreadsafe 18/05/2024