Created
October 28, 2011 05:43
-
-
Save shigeki/1321702 to your computer and use it in GitHub Desktop.
Hello World by libuv
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 <stdio.h> | |
#include "uv.h" | |
static void cb(uv_write_t* req, int status) { | |
printf("Hello from Callback.\n"); | |
uv_unref(uv_default_loop()); | |
} | |
int main() { | |
uv_tty_t tty; | |
uv_write_t req; | |
int ret = uv_tty_init(uv_default_loop(), &tty, 1, 0); | |
uv_buf_t bufs[] = {uv_buf_init("Hello UV!\n",10)}; | |
ret = uv_write(&req, (uv_stream_t*)&tty, bufs, 1, cb); | |
uv_run(uv_default_loop()); | |
return 0; | |
} |
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
hello_uv: hello_uv.c | |
gcc -g -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I../libuv/include -o hello_uv hello_uv.c ../libuv/uv.a -pthread -lrt -lm | |
clean: | |
rm hello_uv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment