Skip to content

Commit d4b50ff

Browse files
Clarify int main(void) example
The semicolon can elicit a syntax error from C compilers such as MSVC. Specifying a return is useful: in ISO C ("C99") and later, the `return 0;` is implied. However, in ANSI C (AKA "C89") the compiler is not required to add `return 0;`. This document references ANSI C, so clarity on the matter and consistent style is best. Also, it is best to identify the struct with the bit layout in question.
1 parent b174a6e commit d4b50ff

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

docs/c-language/c-bit-fields.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,16 @@ struct mybitfields
5656
unsigned short c : 7;
5757
} test;
5858
59-
int main( void );
59+
int main( void )
6060
{
6161
test.a = 2;
6262
test.b = 31;
6363
test.c = 0;
64+
return 0;
6465
}
6566
```
6667

67-
the bits would be arranged as follows:
68+
the bits of `test` would be arranged as follows:
6869

6970
```
7071
00000001 11110010

0 commit comments

Comments
 (0)