Skip to content

Commit 34e0579

Browse files
committed
get rid of the main() without (void) plague
1 parent b1003aa commit 34e0579

File tree

145 files changed

+146
-146
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+146
-146
lines changed

c/abs.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include "common.h"
1010

11-
int main() {
11+
int main(void) {
1212
assert(abs(-1) == 1);
1313

1414
/*

c/array_designated_initializer.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#include "common.h"
1515

16-
int main() {
16+
int main(void) {
1717
#if __STDC_VERSION__ >= 199901L
1818
{
1919
int is[] = {

c/assert_h.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#include "common.h"
1616

17-
int main() {
17+
int main(void) {
1818
assert(1);
1919
return EXIT_SUCCESS;
2020
}

c/atexit.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ void atexit_func() {
1212
printf("atexit\n");
1313
}
1414

15-
int main() {
15+
int main(void) {
1616
atexit(atexit_func);
1717
return EXIT_SUCCESS;
1818
}

c/auto.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#include "common.h"
1111

12-
int main() {
12+
int main(void) {
1313
/* SAME: */
1414
int i;
1515
auto int i2;

c/bitfield.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#include "common.h"
88

9-
int main() {
9+
int main(void) {
1010
struct S {
1111
unsigned b1 : 1;
1212
unsigned b2 : 2;

c/comments.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#include "common.h"
88

9-
int main() {
9+
int main(void) {
1010
/* Standard multi line comment. */
1111
/*
1212
assert(false);

c/complex_h.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
#include "common.h"
4242

43-
int main() {
43+
int main(void) {
4444
#if __STDC_VERSION__ >= 199901L
4545
#ifndef __STDC_NO_COMPLEX__
4646
puts("!__STDC_NO_COMPLEX__");

c/compound_literal.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void func_struct_1(struct func_struct s) {
2121
assert(s.i == 1);
2222
}
2323

24-
int main() {
24+
int main(void) {
2525
#if __STDC_VERSION__ >= 199901L
2626
/* Compound literals for arrays */
2727
{

c/compound_struct_literal.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include "common.h"
1010

11-
int main() {
11+
int main(void) {
1212
struct S { int i; int j; };
1313

1414
/* Basic example. */

c/constant_expression.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*/
2424
#include "common.h"
2525

26-
int main() {
26+
int main(void) {
2727
const int i = 0;
2828

2929
/* ERROR: not a constant expression. */

c/enum.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "common.h"
22

3-
int main() {
3+
int main(void) {
44
/*
55
# Terminology
66

c/errno_h.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
#include "common.h"
2828

29-
int main() {
29+
int main(void) {
3030
/* No error */
3131
errno = 0;
3232

c/exit.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ void exit_func() {
1414
exit(EXIT_SUCCESS);
1515
}
1616

17-
int main() {
17+
int main(void) {
1818
exit_func();
1919
/* Never gets run */
2020
return EXIT_FAILURE;

c/extern/main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void printMain() {
4646

4747
void printA();
4848

49-
int main() {
49+
int main(void) {
5050
printA();
5151
printMain();
5252
printf("commonUninitInt = %d\n", commonUninitInt);

c/float_h.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#include "common.h"
1414

15-
int main() {
15+
int main(void) {
1616
/*
1717
# Rounding method
1818

c/for.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
#include "common.h"
2222

23-
int main() {
23+
int main(void) {
2424
/* Basic example. */
2525
{
2626
int i;

c/function_pointer.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ int int_func_func_int_int(int (*function_ptr)(int, int), int m, int n) {
2121
return (*function_ptr)(m, n);
2222
}
2323

24-
int main() {
24+
int main(void) {
2525
/*
2626
Basic usage.
2727

c/generic.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#include "common.h"
88

9-
int main() {
9+
int main(void) {
1010
#if __STDC_VERSION__ >= 201112L
1111
#if defined(__GNUC__) && (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9))
1212
#define typename(x) _Generic((x), \

c/getenv.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include "common.h"
1010

11-
int main() {
11+
int main(void) {
1212
printf("HOME = %s\n", getenv("HOME"));
1313
assert(getenv("NOT_DEFINED") == NULL);
1414
return EXIT_SUCCESS;

c/goto.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ int goto_func(int i) {
1212
return 1;
1313
}
1414

15-
int main() {
15+
int main(void) {
1616
/*
1717
However, avoid using this as it may generate unreadable code.
1818

c/hello_world.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <stdio.h>
22
#include <stdlib.h>
33

4-
int main() {
4+
int main(void) {
55
puts("hello world");
66
return EXIT_SUCCESS;
77
}

c/identifier.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "common.h"
22

3-
int main() {
3+
int main(void) {
44
/*
55
# Identifiers
66

c/identifier_list.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void g() {}
2020
/* Identifier type list. This one is not optional. */
2121
void h(void) {}
2222

23-
int main() {
23+
int main(void) {
2424
assert(f(1, 2) == 3);
2525
return EXIT_SUCCESS;
2626
}

c/if.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include "common.h"
44

5-
int main() {
5+
int main(void) {
66
/* Only 0 counts as false. */
77
if (0) {
88
assert(0);

c/incomplete_type.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#include "common.h"
1414

15-
int main() {
15+
int main(void) {
1616

1717
/*
1818
TODO what are all possible types of incomplete types?

c/interactive/abort.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void atexit_func() {
2222
printf("atexit\n");
2323
}
2424

25-
int main() {
25+
int main(void) {
2626
/* Will not get called. */
2727
atexit(atexit_func);
2828
abort();

c/interactive/assert_fail.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include "common.h"
1010

11-
int main() {
11+
int main(void) {
1212
assert(0);
1313
puts("here");
1414
return EXIT_SUCCESS;

c/interactive/branch_prediction_and_patterns_perf.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ void f(long p) {
1515
sum++;
1616
}
1717

18-
int main() {
18+
int main(void) {
1919
f(INT_MIN);
2020
f(-1);
2121
f(1);

c/interactive/clock.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#include "common.h"
66

7-
int main() {
7+
int main(void) {
88
clock_t t;
99
uintmax_t i, j;
1010

c/inttypes_h.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#include "common.h"
66

7-
int main() {
7+
int main(void) {
88
#if __STDC_VERSION__ >= 199901L
99
/*
1010
# PRIxPTR

c/iso646_h.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
#include "common.h"
2121

22-
int main() {
22+
int main(void) {
2323
assert(1 and 1);
2424
assert(0 or 1);
2525
return EXIT_SUCCESS;

c/limits_h.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#include "common.h"
99

10-
int main() {
10+
int main(void) {
1111
{
1212
/*
1313
# CHAR_BIT

c/literals.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@
2323

2424
#include "common.h"
2525

26-
int main() {
26+
int main(void) {
2727
return EXIT_SUCCESS;
2828
}

c/main_function.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*
1515
* Valid signatures: either:
1616
*
17-
* int main()
17+
* int main(void)
1818
*
1919
* or:
2020
*

c/malloc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
#include "common.h"
3535

36-
int main() {
36+
int main(void) {
3737
/* Basic usage */
3838
{
3939
size_t bytes = sizeof(int) * 2;

c/min.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
int main() {
1+
int main(void) {
22
return 0;
33
}

c/ndebug.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <assert.h>
1111
#include <stdlib.h>
1212

13-
int main() {
13+
int main(void) {
1414
assert(0);
1515
return EXIT_SUCCESS;
1616
}

c/no_return_non_void.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ int f() {}
1616
#endif
1717
#endif
1818

19-
int main() {
19+
int main(void) {
2020
#if __STDC_VERSION__ >= 199901L
2121
#ifdef UNDEFINED_BEHAVIOUR
2222
f();

c/noreturn.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ noreturn
2727
#endif
2828
void g() { exit(0); }
2929

30-
int main() {
30+
int main(void) {
3131
#if __STDC_VERSION__ >= 201112L
3232
f();
3333
g();

c/null.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161

6262
int *ip;
6363

64-
int main() {
64+
int main(void) {
6565
/*
6666
It never points to any possible valid memory location:
6767
global, local variable, malloc return, ...

c/offsetof.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#include "common.h"
1313

14-
int main() {
14+
int main(void) {
1515
/* Basic example. */
1616
{
1717
struct S {

c/operator.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ int int_func_int(int i) {
1111
return i;
1212
}
1313

14-
int main() {
14+
int main(void) {
1515
/*
1616
# Arithmetic operators
1717

c/parameter_without_name.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ int f(int i, float g) { return i + (int)g; }
2222

2323
int void_parameter(void) { return 1; }
2424

25-
int main() {
25+
int main(void) {
2626
assert(f(1, 1.5) == 2);
2727

2828
/* The exception is the "void paramter". */

c/pointer.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include "common.h"
1010

11-
int main() {
11+
int main(void) {
1212
int i;
1313
int *pi, *pi2;
1414
/* BAD */

0 commit comments

Comments
 (0)