cesanta / mongoose-os

Mongoose OS - an IoT Firmware Development Framework. Supported microcontrollers: ESP32, ESP8266, CC3220, CC3200, STM32F4, STM32L4, STM32F7. Amazon AWS IoT, Microsoft Azure, Google IoT Core integrated. Code in C or JavaScript.
https://mongoose-os.com
Other
2.51k stars 429 forks source link

ffi_exports.c - error: conflicting types #414

Closed christianmue1980a closed 6 years ago

christianmue1980a commented 6 years ago

Hi,

i get the following message during compile:

CC /fwbuild-volumes/1.26/apps/firmware/esp32/build_contexts/build_ctx_988615689/build/objs/ffi_exports.o /fwbuild-volumes/1.26/apps/firmware/esp32/build_contexts/build_ctx_988615689/build/gen/ffi_exports.c:29:6: error: conflicting types for 'getCO2' int getCO2(void); ^ /fwbuild-volumes/1.26/apps/firmware/esp32/build_contexts/build_ctx_988615689/build/gen/ffi_exports.c:28:6: note: previous declaration of 'getCO2' was here void getCO2(void); ^

In my mos.yml I have declared

ffi_symbols:
  - getCO2

My main.h contains

#ifdef __cplusplus
#if __cplusplus
extern "C"{
#endif
#endif /* __cplusplus */

  int getCO2(void) {
        return shared_co2;
    }
//.h end
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */`

init.js

    let getCO2 = ffi('int getCO2()');
    print(getCO2(), "ppm");

Maybe this issue is related to https://github.com/cesanta/mjs/issues/28? Is my code wrong or is there a bug when writing the ffi_exports.c file?

thanks in advance!

christianmue1980a commented 6 years ago

Ok, seems like the solution is to not use the ffi-symbols anymore.