Macbook上sublime的C++11弥补bits/stdc++.h的配置
如果在windows配置过的话这次会容易很多。相关博客很多了,我这里保存一下我借鉴并成功的配置:
关于自己build的C++,文件类型为sublime-build,直接扔在它给出的user文件夹即可,不必特意指定:
1 { 2 "cmd": ["clang++", "${file}","-std=c++11", "-stdlib=libc++", "-o", "${file_path}/${file_base_name}"], 3 "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$", 4 "working_dir": "${file_path}", 5 "selector": "source.c, source.c++", 6 7 "variants": 8 [ 9 { 10 "name": "Run", 11 "cmd": ["bash", "-c", "clang++ '${file}' -std=c++11 -stdlib=libc++ -o '${file_path}/${file_base_name}' && open -a Terminal.app '${file_path}/${file_base_name}'"] 12 } 13 ] 14 }
然鹅这个在终端运行没有我原来在win10的那个配置方便,不过有command+W快捷键关闭,就这样吧……
然后据说Mac不支持bits/stdc++.h,那么就换一种偷懒的方式……依次进入tools、developer、new snippet,建一个上图的acm.sublime-snippet,我使用的是:
1 <snippet> 2 <content><![CDATA[ 3 #pragma comment(linker, "/STACK:1024000000,1024000000") 4 #include <cstdio> 5 #include <cstring> 6 #include <cstdlib> 7 #include <cmath> 8 #include <ctime> 9 #include <cctype> 10 #include <climits> 11 #include <iostream> 12 #include <iomanip> 13 #include <algorithm> 14 #include <random> 15 #include <string> 16 #include <sstream> 17 #include <stack> 18 #include <queue> 19 #include <set> 20 #include <map> 21 #include <vector> 22 #include <list> 23 #include <fstream> 24 #define ri readint() 25 #define gc getchar() 26 #define R(x) scanf("%d", &x) 27 #define W(x) printf("%d\n", x) 28 #define init(a, b) memset(a, b, sizeof(a)) 29 #define rep(i, a, b) for (int i = a; i <= b; i++) 30 #define irep(i, a, b) for (int i = a; i >= b; i--) 31 using namespace std; 32 33 typedef long long ll; 34 typedef unsigned long long ull; 35 typedef pair<int, int> P; 36 const int inf = 0x3f3f3f3f; 37 const ll INF = 1e18; 38 39 ]]></content> 40 <!-- Optional: Set a tabTrigger to define how to trigger the snippet --> 41 <tabTrigger>acm</tabTrigger> 42 <!-- Optional: Set a scope to limit where the snippet will trigger --> 43 <scope>source.c++</scope> 44 </snippet>
根据自己习惯进行改写。这部分内容的使用方法详见且多谢这位前辈的博客