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>
40 lines
973 B
C
40 lines
973 B
C
/*
|
|
* Copyright (c) 2018 Bosch Sensortec GmbH
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#include <zephyr/kernel.h>
|
|
#include <zephyr/device.h>
|
|
#include <zephyr/drivers/sensor.h>
|
|
#include <stdio.h>
|
|
|
|
int main(void)
|
|
{
|
|
const struct device *const dev = DEVICE_DT_GET_ONE(bosch_bme680);
|
|
struct sensor_value temp, press, humidity, gas_res;
|
|
|
|
if (!device_is_ready(dev)) {
|
|
printk("sensor: device not ready.\n");
|
|
return 0;
|
|
}
|
|
|
|
printf("Device %p name is %s\n", dev, dev->name);
|
|
|
|
while (1) {
|
|
k_sleep(K_MSEC(3000));
|
|
|
|
sensor_sample_fetch(dev);
|
|
sensor_channel_get(dev, SENSOR_CHAN_AMBIENT_TEMP, &temp);
|
|
sensor_channel_get(dev, SENSOR_CHAN_PRESS, &press);
|
|
sensor_channel_get(dev, SENSOR_CHAN_HUMIDITY, &humidity);
|
|
sensor_channel_get(dev, SENSOR_CHAN_GAS_RES, &gas_res);
|
|
|
|
printf("T: %d.%06d; P: %d.%06d; H: %d.%06d; G: %d.%06d\n",
|
|
temp.val1, temp.val2, press.val1, press.val2,
|
|
humidity.val1, humidity.val2, gas_res.val1,
|
|
gas_res.val2);
|
|
}
|
|
return 0;
|
|
}
|