企鹅's Blog

Happy coding

TinyC 把 C 代码当脚本运行的编译器

企鹅 posted @ 2009年5月13日 21:56 in C/C++ 语言 , 1183 阅读

主页:

http://bellard.org/tcc/

介绍文章:

http://www.ibm.com/developerworks/cn/linux/l-tinyc/part1/

像这样:

 

#!/usr/bin/tcc -run -L/usr/X11R6/lib -lX11
#include <stdlib.h>
/* Yes, TCC can use X11 too ! */
#include <stdio.h>
#include <X11/Xlib.h>

int main(int argc, char **argv)
{
    Display *display;
    Screen *screen;

    display = XOpenDisplay("");
    if (!display) {
        fprintf(stderr, "Could not open X11 display\n");
        exit(1);
    }
    printf("X11 display opened.\n");
    screen = XScreenOfDisplay(display, 0);
    printf("width = %d\nheight = %d\ndepth = %d\n",
           screen->width,
           screen->height,
           screen->root_depth);
    XCloseDisplay(display);
    return 0;
}
 

 

 


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter