Skip to content

Instantly share code, notes, and snippets.

@klutzy
Last active December 27, 2015 15:59
Show Gist options
  • Save klutzy/7351873 to your computer and use it in GitHub Desktop.
Save klutzy/7351873 to your computer and use it in GitHub Desktop.
test code for mingw / libuv / _CRT_NON_CONFORMING_SWPRINTFS
// test code for mingw / libuv / _CRT_NON_CONFORMING_SWPRINTFS
// compare result with libuv built with different configurations:
// $ make
// $ make CFLAGS="-D_CRT_NON_CONFORMING_SWPRINTFS"
#include <stdio.h>
#include <io.h>
#include <fcntl.h>
#include "uv.h"
uv_fs_t req;
void cb(uv_fs_t* req);
const char* path = "C:\\";
int main() {
uv_loop_t* loop = uv_default_loop();
int res = uv_fs_readdir(loop, &req, path, O_RDONLY, cb);
if (res) {
fprintf(stderr, "uv_fs_readdir err: %s.\n", uv_strerror(res));
return -1;
}
uv_run(loop, UV_RUN_DEFAULT);
return 0;
}
void cb(uv_fs_t* req) {
int result = req->result;
if (result == -1) {
printf("no result\n");
} else {
printf("out: %s\n", req->ptr);
}
uv_fs_req_cleanup(req);
}
@klutzy
Copy link
Author

klutzy commented Nov 8, 2013

Tested with latest libuv and mingw w32api-4.0.0.
libuv built by make CFLAGS="-D_CRT_NON_CONFORMING_SWPRINTFS" works well, but make (no -D) one segfaults.

On mingw-w64 (32bit) both are ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment