As both C and C++ standards require applications running under an OS to
return 'int', adapt that for Zephyr to align with those standard. This also
eliminates errors when building with clang when not using -ffreestanding,
and reduces the need for compiler flags to silence warnings for both clang
and gcc.
Most of these changes were automated using coccinelle with the following
script:
@@
@@
- void
+ int
main(...) {
...
- return;
+ return 0;
...
}
Approximately 40 files had to be edited by hand as coccinelle was unable to
fix them.
Signed-off-by: Keith Packard <keithp@keithp.com>
44 lines
1.1 KiB
C
44 lines
1.1 KiB
C
/*
|
|
* Copyright (c) 2020 Nordic Semiconductor ASA
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#if defined(CONFIG_APP_FORMATTER_PRINTK)
|
|
#include <zephyr/sys/printk.h>
|
|
#define PRINT_S "printk"
|
|
#define PRINT(...) printk(__VA_ARGS__)
|
|
#elif defined(CONFIG_APP_FORMATTER_PRINTF)
|
|
#include <stdio.h>
|
|
#ifdef CONFIG_NEWLIB_LIBC
|
|
#define PRINT_S "printf/newlib"
|
|
#else /* NEWLIB_LIBC */
|
|
#define PRINT_S "printf"
|
|
#endif /* NEWLIB_LIBC */
|
|
#define PRINT(...) printf(__VA_ARGS__)
|
|
#elif defined(CONFIG_APP_FORMATTER_PRINTFCB)
|
|
#include <zephyr/sys/cbprintf.h>
|
|
#ifdef CONFIG_NEWLIB_LIBC
|
|
#define PRINT_S "printfcb/newlib"
|
|
#else /* NEWLIB_LIBC */
|
|
#define PRINT_S "printfcb"
|
|
#endif /* NEWLIB_LIBC */
|
|
#define PRINT(...) printfcb(__VA_ARGS__)
|
|
#elif defined(CONFIG_APP_FORMATTER_FPRINTF)
|
|
#include <stdio.h>
|
|
#define PRINT_S "fprintf"
|
|
#define PRINT(...) fprintf(stdout, __VA_ARGS__)
|
|
#elif defined(CONFIG_APP_FORMATTER_FPRINTFCB)
|
|
#include <zephyr/sys/cbprintf.h>
|
|
#define PRINT_S "fprintfcb"
|
|
#define PRINT(...) fprintfcb(stdout, __VA_ARGS__)
|
|
#else
|
|
#error Unsupported configuration
|
|
#endif
|
|
|
|
int main(void)
|
|
{
|
|
PRINT("Hello with %s on %s\nComplete\n", PRINT_S, CONFIG_BOARD);
|
|
return 0;
|
|
}
|