golang の gc が十分に効果的ではないため、大量のオブジェクト (約 1 億オブジェクト) をメモリに malloc したいので、c/c++ を使用してメモリを malloc し、std::vector を使用してオブジェクトを保持する必要があります。これは私のコードです。cgo で std コンテナーを使用したいです。
package main
import (
"fmt"
)
/*
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
using namespace std;
void dosome(){
vector<int> ivec; // empty vector
for (vector<int>::size_type ix = 0; ix != 10; ++ix)
ivec[ix] = ix; // disaster: ivec has no elements
}
*/
// #cgo LDFLAGS: -lstdc++
import "C"
//import "fmt"
func main() {
C.dosome()
var input string
fmt.Scanln(&input)
}
以下のエラーメッセージがあります:
go run stddemo.go
# command-line-arguments
./stddemo.go:13:10: fatal error: 'vector' file not found
#include <vector>
^
1 error generated.
インクルードパスを設定するにはどうすればよいですか、それとも別のアイデアがありますか?