我有一个带有自定义系统调用的Linux内核.在C中,我可以使用标准C库syscall()通过其编号调用系统调用.如何在Go中调用此新系统调用?
在C中,在Linux上,还有一些宏可以发出所需的内联汇编以直接进行系统调用.
我不想讨厌syscall_linux.go.
我在Go中看到,syscall_linux.go由perl脚本(mysyscall.pl)处理以生成程序集.这也是相当复杂的,并且黑客它生成一个新的存根也似乎不必要地凌乱.
我想有一个成员函数的指针成员.然后我可以将此指针设置为指向其他成员函数之一,并使用它来调用我真正想要的函数.本质上我有不同的方法来实现一个函数,我想设置一个指针来调用适当的函数.该类也是模板类.
我找不到通过函数指针调用函数的方法.例如:
template <typename T> class C
{
public:
typedef void(C<T>::*Cfunc)(int);
Cfunc cf;
void p1(int i) {
}
C (int i)
{
cf = &C<T>::p1;
}
};
int main ()
{
C<int> Try1(1);
(Try1.*C<int>::cf)(10);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我收到错误:
tc.cpp: In function ‘int main()’:
tc.cpp:5:11: error: invalid use of non-static data member ‘C<int>::cf’
Cfunc cf;
^
tc.cpp:16:16: error: from this location
(Try1.*C<int>::cf)(10);
Run Code Online (Sandbox Code Playgroud)