Skip to content

Instantly share code, notes, and snippets.

@shigeki
Created October 28, 2011 05:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shigeki/1321702 to your computer and use it in GitHub Desktop.
Save shigeki/1321702 to your computer and use it in GitHub Desktop.
Hello World by libuv
#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;
}
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