admin 管理员组

文章数量: 1088139

一、下载并安装最新版clang (for windows)

地址:http://www.llvm/releases/download.html

安装时选中添加 LLVM 到 path。

二、编译代码。

有 tmp,内容如下:

#include <iostream>
#include <vector>
using namespace std;

int main()
{
	vector<int> v;
	for (int i = 0; i < 5; ++i)
		v.push_back(i);
	if (1 == 1) {
		cout << "This is 1" << endl;
		cout << "too many spaces" << endl;
	} else {
		cout << "haha else!" << endl;
	}
	cout << "end" << endl;
	for (auto &x : v)
		cout << &x << ' ';
	cout << endl;
	for (auto x : v)
		cout << &x << ' ';
	cout << endl;
}


编译命令为:
clang++ -Xclang -flto-visibility-public-std -std=c++14 tmp

clang-cl tmp

(参考:https://stackoverflow/questions/42545078/clang-version-5-and-lnk4217-warning)

本文标签: Windows Clang