Created
June 5, 2024 01:03
-
-
Save cho0h5/bbaedb8112d5e62623742b10b5b73431 to your computer and use it in GitHub Desktop.
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
// gcc -lcurl curl_without_error_handling.c && ./a.out | |
#include <curl/curl.h> | |
int main() { | |
CURL *curl = curl_easy_init(); | |
curl_easy_setopt(curl, CURLOPT_URL, "https://ziglang.org"); | |
curl_easy_perform(curl); | |
curl_easy_cleanup(curl); | |
return 0; | |
} |
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
// you should add the two lines below into build.zig | |
// exe.linkSystemLibrary("libcurl"); | |
// exe.linkLibC(); | |
// and the, run `zig build run` | |
const cURL = @cImport({ | |
@cInclude("curl/curl.h"); | |
}); | |
pub fn main() !void { | |
const handle = cURL.curl_easy_init(); | |
defer cURL.curl_easy_cleanup(handle); | |
_ = cURL.curl_easy_setopt(handle, cURL.CURLOPT_URL, "https://ziglang.org"); | |
_ = cURL.curl_easy_perform(handle); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment