Last active
December 27, 2015 15:59
-
-
Save klutzy/7351873 to your computer and use it in GitHub Desktop.
test code for mingw / libuv / _CRT_NON_CONFORMING_SWPRINTFS
This file contains 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
// 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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tested with latest libuv and mingw w32api-4.0.0.
libuv built by
make CFLAGS="-D_CRT_NON_CONFORMING_SWPRINTFS"
works well, butmake
(no-D
) one segfaults.On mingw-w64 (32bit) both are ok.