diff options
author | Mitchell de Bruyn <mitch@physicscat.org> | 2013-11-21 12:51:37 +0200 |
---|---|---|
committer | Uli Schlachter <psychon@znc.in> | 2013-11-23 11:48:52 +0100 |
commit | a42a48b95ed78e4dd1f52da59bc7224b79d34553 (patch) | |
tree | 6a39d1a3e18cd2e2176e4f6fdd5f65b148e181e5 | |
parent | 8c11fec5fb920f4ecf7ccf464036b2f74b1f2af5 (diff) |
Change tutorial printf statements to use inttypes
Include - inttypes.h
Changed printf formatting string such as %d and %ld to the appropriate:
PRIu32, PRIi16, PRIu8, Et Cetera.
-rw-r--r-- | tutorial.mdwn | 11 | ||||
-rw-r--r-- | tutorial/events.mdwn | 23 | ||||
-rw-r--r-- | tutorial/fonts.mdwn | 3 | ||||
-rw-r--r-- | tutorial/mousecursors.mdwn | 3 |
4 files changed, 22 insertions, 18 deletions
diff --git a/tutorial.mdwn b/tutorial.mdwn index 6e56706..3c26c46 100644 --- a/tutorial.mdwn +++ b/tutorial.mdwn @@ -354,6 +354,7 @@ Here is a small program that shows how to use this function: #include <stdio.h> #include <xcb/xcb.h> + #include <inttypes.h> int main () @@ -380,11 +381,11 @@ Here is a small program that shows how to use this function: /* report */ printf ("\n"); - printf ("Informations of screen %ld:\n", screen->root); - printf (" width.........: %d\n", screen->width_in_pixels); - printf (" height........: %d\n", screen->height_in_pixels); - printf (" white pixel...: %ld\n", screen->white_pixel); - printf (" black pixel...: %ld\n", screen->black_pixel); + printf ("Informations of screen %"PRIu32":\n", screen->root); + printf (" width.........: %"PRIu16"\n", screen->width_in_pixels); + printf (" height........: %"PRIu16"\n", screen->height_in_pixels); + printf (" white pixel...: %"PRIu32"\n", screen->white_pixel); + printf (" black pixel...: %"PRIu32"\n", screen->black_pixel); printf ("\n"); return 0; diff --git a/tutorial/events.mdwn b/tutorial/events.mdwn index 66232ba..bde3624 100644 --- a/tutorial/events.mdwn +++ b/tutorial/events.mdwn @@ -307,6 +307,7 @@ As an example for handling events, we show a program that creates a window, ente #include <stdlib.h> #include <stdio.h> + #include <inttypes.h> #include <xcb/xcb.h> @@ -371,7 +372,7 @@ As an example for handling events, we show a program that creates a window, ente case XCB_EXPOSE: xcb_expose_event_t *expose = (xcb_expose_event_t *)event; - printf ("Window %ld exposed. Region to be redrawn at location (%d,%d), with dimension (%d,%d)\n", + printf ("Window %"PRIu32" exposed. Region to be redrawn at location (%"PRIu16",%"PRIu16"), with dimension (%"PRIu16",%"PRIu16")\n", expose->window, expose->x, expose->y, expose->width, expose->height ); break; @@ -381,15 +382,15 @@ As an example for handling events, we show a program that creates a window, ente switch (press->detail) { case 4: - printf ("Wheel Button up in window %ld, at coordinates (%d,%d)\n", + printf ("Wheel Button up in window %"PRIu32", at coordinates (%"PRIi16",%"PRIi16")\n", bp->event, bp->event_x, bp->event_y ); break; case 5: - printf ("Wheel Button down in window %ld, at coordinates (%d,%d)\n", + printf ("Wheel Button down in window %"PRIu32", at coordinates (%"PRIi16",%"PRIi16")\n", bp->event, bp->event_x, bp->event_y ); break; default: - printf ("Button %d pressed in window %ld, at coordinates (%d,%d)\n", + printf ("Button %"PRIu8" pressed in window %"PRIu32", at coordinates (%"PRIi16",%"PRIi16")\n", bp->detail, bp->event, bp->event_x, bp->event_y ); break; } @@ -398,28 +399,28 @@ As an example for handling events, we show a program that creates a window, ente xcb_button_release_event_t *br = (xcb_button_release_event_t *)event; print_modifiers(br->state); - printf ("Button %d released in window %ld, at coordinates (%d,%d)\n", + printf ("Button %"PRIu8" released in window %"PRIu32", at coordinates (%"PRIi16",%"PRIi16")\n", br->detail, br->event, br->event_x, br->event_y ); break; case XCB_MOTION_NOTIFY: xcb_motion_notify_event_t *motion = (xcb_motion_notify_event_t *)event; - printf ("Mouse moved in window %ld, at coordinates (%d,%d)\n", + printf ("Mouse moved in window %"PRIu32", at coordinates (%"PRIi16",%"PRIi16")\n", motion->event, motion->event_x, motion->event_y ); break; case XCB_ENTER_NOTIFY: xcb_enter_notify_event_t *enter = (xcb_enter_notify_event_t *)event; - printf ("Mouse entered window %ld, at coordinates (%d,%d)\n", + printf ("Mouse entered window %"PRIu32", at coordinates (%"PRIi16",%"PRIi16")\n", enter->event, enter->event_x, enter->event_y ); break; case XCB_LEAVE_NOTIFY: xcb_leave_notify_event_t *leave = (xcb_leave_notify_event_t *)event; - printf ("Mouse left window %ld, at coordinates (%d,%d)\n", + printf ("Mouse left window %"PRIu32", at coordinates (%"PRIi16",%"PRIi16")\n", leave->event, leave->event_x, leave->event_y ); break; @@ -427,7 +428,7 @@ As an example for handling events, we show a program that creates a window, ente xcb_key_press_event_t *kp = (xcb_key_press_event_t *)event; print_modifiers(kp->state); - printf ("Key pressed in window %ld\n", + printf ("Key pressed in window %"PRIu32"\n", kp->event); break; @@ -435,13 +436,13 @@ As an example for handling events, we show a program that creates a window, ente xcb_key_release_event_t *kr = (xcb_key_release_event_t *)event; print_modifiers(kr->state); - printf ("Key released in window %ld\n", + printf ("Key released in window %"PRIu32"\n", kr->event); break; default: /* Unknown event type, ignore it */ - printf ("Unknown event: %d\n", + printf ("Unknown event: %"PRIu8"\n", event->response_type); break; } diff --git a/tutorial/fonts.mdwn b/tutorial/fonts.mdwn index b9d6ee4..88d4fa0 100644 --- a/tutorial/fonts.mdwn +++ b/tutorial/fonts.mdwn @@ -70,6 +70,7 @@ This example draw a text at 10 pixels (for the base line) of the bottom of a win #include <stdlib.h> #include <stdio.h> #include <string.h> + #include <inttypes.h> #include <xcb/xcb.h> @@ -98,7 +99,7 @@ This example draw a text at 10 pixels (for the base line) of the bottom of a win { xcb_generic_error_t *error = xcb_request_check (connection, cookie); if (error) { - fprintf (stderr, "ERROR: %s : %d\n", errMessage , error->error_code); + fprintf (stderr, "ERROR: %s : %"PRIu8"\n", errMessage , error->error_code); xcb_disconnect (connection); exit (-1); } diff --git a/tutorial/mousecursors.mdwn b/tutorial/mousecursors.mdwn index c49041f..67e6319 100644 --- a/tutorial/mousecursors.mdwn +++ b/tutorial/mousecursors.mdwn @@ -69,6 +69,7 @@ The following example displays a window with a button. When entering the window, #include <stdlib.h> #include <stdio.h> #include <string.h> + #include <inttypes.h> #include <xcb/xcb.h> @@ -90,7 +91,7 @@ The following example displays a window with a button. When entering the window, { xcb_generic_error_t *error = xcb_request_check (connection, cookie); if (error) { - fprintf (stderr, "ERROR: %s : %d\n", errMessage , error->error_code); + fprintf (stderr, "ERROR: %s : %"PRIu8"\n", errMessage , error->error_code); xcb_disconnect (connection); exit (-1); } |