llvm&clang 源码编译
下载源码
git clone https://github.com/llvm/llvm-project.git
编译
- config&compile
see llvm GettingStarted
- 可能缺少的库
sudo apt install swig libedit-dev libxml2-dev ocaml python-pygments python-yaml doxygen
git clone https://github.com/llvm/llvm-project.git
sudo apt install swig libedit-dev libxml2-dev ocaml python-pygments python-yaml doxygen
查看防火墙是否开启 firewall-cmd --state
重载防火墙,使新规则生效 firewall-cmd --complete-reload
查看打开的端口 firewall-cmd --list-ports
sytemctl start firewalld
systemctl stop firewalld
automatic storage duration The storage for the object is allocated at the beginning of the enclosing code block and deallocated at the end. All local objects have this storage duration, except those declared static, extern or thread_local.
static storage duration The storage for the object is allocated when the program begins and deallocated when the program ends. Only one instance of the object exists. All objects declared at namespace scope (including global namespace) have this storage duration, plus those declared with static or extern.
thread_local storage duration The storage for the object is allocated when the thread begins and deallocated when the thread ends. Each thread has its own instance of the object. Only objects declared thread_local have this storage duration. thread_local can appear together with static or extern to adjust linkage.
dynamic storage duration The storage for the object is allocated and deallocated per request by using dynamic memory allocation functions.
the standard Go compiler and gccgo both don't allow local variables declared but not used. Package-level variables have no such limit. If a local variable is only ever used as destination values, it will also be viewed as unused.
The name of the folder of a package is not required to be the same as the package name. However, for a library package, it will make package users confused if the name of the package is different from the name of the folder of the package.
init
function declared in the same package is invoked.The expressions enclosed within the body of an anonymous function call, whether the call is a general call or a deferred/goroutine call, will not be evaluated at the moment when the anonymous function call is invoked.
1 | package main |
output is: a: 2 a: 1 a: 0
b: 3
b: 3
b: 3
to get b: 2, b: 1, b: 0 1
2
3
4
5
6
7func() {
for i := 0; i < 3; i++ {
defer func(i int) {
fmt.Println("b:", i)
}(i)
}
}()
需要针对数组元素的类型大小计算数组的最大长度范围 ([]uint8 最大2GB, []uint16 最大1GB,以此类推),但是 []struct{} 数组的长度可以超过2GB