Skip to content

Instantly share code, notes, and snippets.

@phardy
Created August 18, 2013 06:07
Show Gist options
  • Select an option

  • Save phardy/6260146 to your computer and use it in GitHub Desktop.

Select an option

Save phardy/6260146 to your computer and use it in GitHub Desktop.
Pebble strtol test #2. I declare a long and assign the output of strtol to it in the same statement. The long is not referenced again. This code compiles and runs to completion, showing "done" on the Pebble's display.
#include "pebble_os.h"
#include "pebble_app.h"
#include "pebble_fonts.h"
#define MY_UUID { 0x92, 0x40, 0x44, 0xC0, 0xCA, 0x8A, 0x43, 0x64, 0x9D, 0xDE, 0x11, 0x33, 0x6F, 0x04, 0xA9, 0x3F }
PBL_APP_INFO(MY_UUID,
"strtol test", "Your Company",
1, 0, /* App version */
DEFAULT_MENU_ICON,
APP_INFO_STANDARD_APP);
Window window;
TextLayer textlayer;
void handle_init(AppContextRef ctx) {
window_init(&window, "Window Name");
window_stack_push(&window, true /* Animated */);
text_layer_init(&textlayer, GRect(10, 10, 100, 100));
layer_add_child(&window.layer, &textlayer.layer);
text_layer_set_text(&textlayer, "calling strtol");
char numstr[] = "37";
long mynum = strtol(numstr, NULL, 10);
text_layer_set_text(&textlayer, "done");
}
void pbl_main(void *params) {
PebbleAppHandlers handlers = {
.init_handler = &handle_init
};
app_event_loop(params, &handlers);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment