Created
August 18, 2013 06:17
-
-
Save phardy/6260171 to your computer and use it in GitHub Desktop.
Pebble strtol test #4. This defines a long in the global scope, then attempts to assign the output of strtol to it. This code compiles but crashes at runtime.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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; | |
| long mynum; | |
| 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"; | |
| 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