Last active
January 29, 2020 03:18
-
-
Save naltun/3fc743b11c0dd127cb6dcb9af043daad to your computer and use it in GitHub Desktop.
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
// main.zig | |
const std = @import("std"); | |
const warn = std.debug.warn; | |
const libcurl = @cImport(@cInclude("/usr/include/curl/curl.h")); | |
pub fn main() void { | |
var curl: *libcurl.CURL = libcurl.curl_easy_init(); | |
var res: libcurl.CURLcode = undefined; | |
var url = "https://example.com"; | |
_ = @intToEnum(libcurl.CURLoption, libcurl.CURLOPT_URL); | |
libcurl.curl_easy_setopt(curl, libcurl.CURLOPT_URL, url); | |
res = libcurl.curl_easy_perform(curl); | |
libcurl.curl_easy_cleanup(curl); | |
warn("Success!\n"); | |
} | |
// make | |
[vagrant@test test]$ make | |
zig build-exe src/main.zig \ | |
--name test \ | |
--output-dir release/ \ | |
--library c \ | |
--library curl \ | |
--library-path /usr/lib \ | |
-isystem /usr/include | |
/vagrant/test/src/main.zig:21:43: error: expected type '.cimport:13:17.CURLoption', found 'comptime_int' | |
libcurl.curl_easy_setopt(curl, libcurl.CURLOPT_URL, url); | |
^ | |
zig-cache/o/qD0dy2Mk_lLtIbVxDXeeN6xAzbpvx6OT8J41zSUvSy68U0fd18f2z7LwukiO6e0I/cimport.zig:1329:24: note: .cimport:13:17.CURLoption declared here | |
pub const CURLoption = extern enum { | |
^ | |
/vagrant/eyez/src/main.zig:21:29: note: referenced here | |
libcurl.curl_easy_setopt(curl, libcurl.CURLOPT_URL, url); | |
^ | |
make: *** [Makefile:4: all] Error 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment