maximkulkin / esp-homekit-demo

Demo of Apple HomeKit accessory server library
MIT License
805 stars 233 forks source link

Some Warnings #328

Closed konifer44 closed 4 years ago

konifer44 commented 4 years ago

Hey, my program is working perfectly fine. But I get those warnings: warning: 'esp_event_loop_init' is deprecated [-Wdeprecated-declarations] ESP_ERROR_CHECK(esp_event_loop_init(event_handler, NULL)); ^~~~~~~

esp_err_t esp_event_loop_init(system_event_cb_t cb, void ctx) attribute ((deprecated)); ^~~~~~~ warning: missing initializer for field 'getter_ex' of 'homekit_characteristic_t' {aka 'struct _homekit_characteristic'} [-Wmissing-field-initializers] homekit_characteristic_t target_position = {HOMEKIT_DECLARE_CHARACTERISTIC_TARGET_POSITION(POSITION_OPEN, .callback = HOMEKIT_CHARACTERISTIC_CALLBACK(on_update_target_position))}; ^~~~~~~~ include/homekit/types.h:204:23: note: 'getter_ex' declared here homekit_value_t (getter_ex)(const homekit_characteristic_t ch); ^~~~~ warning: initialized field overwritten [-Woverride-init] HOMEKIT_ACCESSORY(.id = 1, .category = homekit_accessory_category_window_covering, .services = (homekit_service_t []){HOMEKIT_SERVICE(ACCESSORY_INFORMATION, .characteristics = (homekit_characteristic_t []){HOMEKIT_CHARACTERISTIC(NAME, "Roleta"), HOMEKIT_CHARACTERISTIC(MANUFACTURER, "Konifer"), HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, "001"), HOMEKIT_CHARACTERISTIC(MODEL, "Roleta v1.0"), HOMEKIT_CHARACTERISTIC(FIRMWARE_REVISION, "1.0"), HOMEKIT_CHARACTERISTIC(IDENTIFY, window_covering_identify), NULL}), HOMEKIT_SERVICE(WINDOW_COVERING, .primary = true, .characteristics = (homekit_characteristic_t []){HOMEKIT_CHARACTERISTIC(NAME, "Window blind"), &current_position, &target_position, &position_state, NULL}), NULL}), ^~~~~~~~~~ /Users/konifer/Desktop/esp-homekit-demo/components/common/homekit/include/homekit/types.h:236:11: note: in definition of macro 'HOMEKIT_ACCESSORY'

__VA_ARGS__ \

       ^~~~~~~~~~~

/Users/konifer/Desktop/esp-homekit-demo/examples/esp32/window_covering/main/window_covering.c:351:44: note: (near initialization for '(anonymous).category') HOMEKIT_ACCESSORY(.id = 1, .category = homekit_accessory_category_window_covering, .services = (homekit_service_t []){HOMEKIT_SERVICE(ACCESSORY_INFORMATION, .characteristics = (homekit_characteristic_t []){HOMEKIT_CHARACTERISTIC(NAME, "Roleta"), HOMEKIT_CHARACTERISTIC(MANUFACTURER, "Konifer"), HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, "001"), HOMEKIT_CHARACTERISTIC(MODEL, "Roleta v1.0"), HOMEKIT_CHARACTERISTIC(FIRMWARE_REVISION, "1.0"), HOMEKIT_CHARACTERISTIC(IDENTIFY, window_covering_identify), NULL}), HOMEKIT_SERVICE(WINDOW_COVERING, .primary = true, .characteristics = (homekit_characteristic_t *[]){HOMEKIT_CHARACTERISTIC(NAME, "Window blind"), &current_position, &target_position, &position_state, NULL}), NULL}), ^~~~~~~~~~ /Users/konifer/Desktop/esp-homekit-demo/components/common/homekit/include/homekit/types.h:236:11: note: in definition of macro 'HOMEKIT_ACCESSORY'

__VA_ARGS__ \

       ^~~~~~~~~~~

AR build/main/libmain.a

How to get rid of those warnings?

maximkulkin commented 4 years ago

So, some of those warnings (e.g. from HOMEKIT_* macros) are legitimate use which in other places might look suspicious and thus compiler issues those warnings. If you do not want to see them, you can silence them by using pragmas:

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Woverride-init"
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"

homekit_accessory_t *accessories[] = {
    HOMEKIT_ACCESSORY(
        // ...
    ),
    NULL
};

#pragma GCC diagnostic pop

Although there are other warnings in your log that are just because of outdated code using deprecated stuff. Those you can fix by updating code to use latest APIs.