У меня проблема с тестовым приложением im modifying, чтобы лучше познакомиться с Pebble App SDK и C. Im пытается получить мой код для запуска функции inbox_received_callback(DictionaryIterator *iterator, void *context)
, но по какой-то причине C пропускает код и переходит к выполнению других функций. Все другие функции, предварительно записанные в примере, запускаются без проблем.C Skips Function Over
Почему C решит пропустить эту функцию и как предотвратить ее пропущение через этот код.
weather_app_data.c
...other functions listed
void inbox_received_callback(DictionaryIterator *iterator, void *context) {
// Store incoming information
strcpy(city, "test");
static char temperature_buffer[8];
static char conditions_buffer[32];
static char weather_layer_buffer[32];
// Read first item
Tuple *t = dict_read_first(iterator);
// For all items
while(t != NULL) {
// Which key was received?
switch(t->key) {
case KEY_0:
snprintf(temperature_buffer, sizeof(temperature_buffer), "%dC", (int)t->value->int32);
break;
case KEY_1:
snprintf(conditions_buffer, sizeof(conditions_buffer), "%s", t->value->cstring);
break;
default:
APP_LOG(APP_LOG_LEVEL_ERROR, "Key %d not recognized!", (int)t->key);
break;
}
// Look for next item
t = dict_read_next(iterator);
}
}
}
static WeatherAppDataPoint s_data_points[] = {
{
.city = city, //This value is left blank by C even though defined in function that isn't running
.description = "Light Rain.",
.icon = WEATHER_APP_ICON_LIGHT_RAIN,
.current = 68,
.high = 70,
.low = 60,
},
...other items
};
weather_app_data.h
... other functions all listed
void inbox_received_callback(DictionaryIterator *iterator, void *context);
void inbox_dropped_callback(AppMessageResult reason, void *context);
void outbox_failed_callback(DictionaryIterator *iterator, AppMessageResult reason, void *context);
Итак, вы исключаете, что 'Tuple * t = dict_read_first (iterator);' никогда не возвращает 'NULL'? Если у вас нет отладчика, добавьте строку 'if (t) printf (" t не NULL \ n ");' ниже того, который нужно проверить. – usr2564301
Где код, вызывающий 'inbox_received_callback()'? Написание функции недостаточно. Некоторую другую функцию нужно назвать. – Peter
Какое доказательство у вас есть, что «* C пропускает код *»? –