C99 supports universal character names that may be used in identifiers, character constants, and string literals to designate characters that are not in the basic character set.
The universal character name \U
nnnnnnnn designates the character whose eight-digit short identifier (as specified by ISO/IEC 10646) is nnnnnnnn. Similarly, the universal
character name \u
nnnn designates the character whose four-digit short identifier is nnnn (and whose eight-digit short identifier is 0000
nnnn).
If a character sequence that matches the syntax of a universal character name is produced by token concatenation, the behavior is undefined.
This code example is non-compliant because it produces a universal character name by token concatenation.
#define assign(uc1, uc2, uc3, uc4, val) uc1##uc2##uc3##uc4 = val; int \U00010401\U00010401\U00010401\U00010402; assign(\U00010401, \U00010401, \U00010401, \U00010402, 4); |
This code solution is compliant.
#define assign(ucn, val) ucn = val; int \U00010401\U00010401\U00010401\U00010402; assign(\U00010401\U00010401\U00010401\U00010402, 4); |
Rule |
Severity |
Likelihood |
Remediation Cost |
Priority |
Level |
---|---|---|---|---|---|
PRE30-C |
1 (low) |
1 (unlikely) |
1 (low) |
P1 |
L3 |