ex4.c 615 B

123456789101112131415161718192021222324252627
  1. #!/usr/local/bin/tcc -run -L/usr/X11R6/lib -lX11
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include <X11/Xlib.h>
  5. /* Yes, TCC can use X11 too ! */
  6. int main(int argc, char **argv)
  7. {
  8. Display *display;
  9. Screen *screen;
  10. display = XOpenDisplay("");
  11. if (!display) {
  12. fprintf(stderr, "Could not open X11 display\n");
  13. exit(1);
  14. }
  15. printf("X11 display opened.\n");
  16. screen = XScreenOfDisplay(display, 0);
  17. printf("width = %d\nheight = %d\ndepth = %d\n",
  18. screen->width,
  19. screen->height,
  20. screen->root_depth);
  21. XCloseDisplay(display);
  22. return 0;
  23. }