File tree Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Original file line number Diff line number Diff line change 55 "fmt"
66 "log"
77 "os"
8+ "os/exec"
89 "strings"
910
1011 "github.com/go-clang/v3.4/clang"
@@ -20,9 +21,23 @@ func main() {
2021 copy (tuArgs , flag .Args ()[1 :])
2122 }
2223 _ = tuArgs
23- cmdArgs := []string {
24- "-std=c99" ,
25- "-I/usr/lib/clang/3.4/include" }
24+
25+ // auto find clang include dir
26+ clincdir := "/usr/lib/clang/3.4/include"
27+ clexe , err := exec .LookPath ("clang" )
28+ if err != nil {
29+ log .Println (err )
30+ } else {
31+ cmdo := exec .Command (clexe , "-print-resource-dir" )
32+ output , err := cmdo .CombinedOutput ()
33+ if err != nil {
34+ log .Println (err )
35+ } else {
36+ clincdir = strings .TrimSpace (string (output ))
37+ }
38+ }
39+
40+ cmdArgs := []string {"-std=c99" , fmt .Sprintf ("-I%s/include" , clincdir )}
2641 tu := idx .ParseTranslationUnit ("/usr/local/include/tox/tox.h" , cmdArgs , nil , 0 )
2742 defer tu .Dispose ()
2843
@@ -90,6 +105,6 @@ func main() {
90105}
91106
92107/*
93- 结构:
108+ result structure:
94109var _enumName_S map[int]string
95110*/
You can’t perform that action at this time.
0 commit comments