Loading page…
Type checking, symbol tables, scope rules, and semantic error detection.
{, function body).}, end of function).Expression Type Rules
// E1 + E2: both must be arithmetic; result = wider type // E1 < E2: both must be comparable; result = bool // E1 = E2: E2 must be assignable to type of E1 // &E: result = pointer to type of E // *E: E must be pointer; result = pointed-to type // f(args): arg types must match parameter types // if (E): E must be bool (or implicitly convertible)
{} visible until end of block.goto targets) visible throughout function body.extern or function prototype tells compiler the type exists.| From \ To | int | float | double | char | void* | int* |
|---|---|---|---|---|---|---|
| int | ✓ | Warn | ✓ | Narrow | Warn | Error |
| float | Warn | ✓ | ✓ | Error | Error | Error |
| double | Warn | Warn | ✓ | Error | Error | Error |
| char | ✓ | ✓ | ✓ | ✓ | Error | Error |
| void* |
#include.struct + int).void value where value expected.break or continue outside for/while/switch.return; in non-void function.const variable or through pointer-to-const.| Error |
| Error |
| Error |
| Error |
| ✓ |
| ✓ |
| int* | Error | Error | Error | Error | ✓ | Error |