我有一个测试应用程序的IM修改,以获得与卵石应用SDK和C.我试着让我的代码运行的功能inbox_received_callback(DictionaryIterator *iterator, void *context)
但无论出于何种原因更好地了解一个问题,C跳过代码并继续运行其他功能。示例中预先写入的所有其他函数运行时没有问题。ç跳过功能在
为什么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跳过代码*”? –