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
local ffi = require("ffi") | |
local t = {1, 2, 3} -- array of floating point numbers | |
-- lua数组 t 也可以是int,float | |
-- ffi.new("float[?]", #t, t) new一个cdata,float数组,大小是#t:3,初始化用t | |
-- ffi.string 当第二个参数有的时候,第一个参数返回的指针类型是变成了void。(可能会导致字节序问题) | |
-- 如果第二个参数没有的话,第一个指针会转换成char*,并且当遇到/0的时候截断,字符串长度是由strlen()确定 | |
local str = ffi.string(ffi.new("float[?]", #t, t), 4 * #t) | |
print(#t) | |
print(str) | |
print(#str) |
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
Go 语言实践:编写可维护的程序的建议 | |
英文:https://dave.cheney.net/practical-go/presentations/qcon-china.html | |
中文:https://github.com/llitfkitfk/go-best-practice | |
Golang 新手可能会踩的 50 个坑 | |
https://segmentfault.com/a/1190000013739000 |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |