简体   繁体   English

如何从tcl脚本运行C方法?

[英]How to run a C method from a tcl script?

I have a C method to add two numbers which looks like this : 我有一个C方法来添加两个看起来像这样的数字:

#include<stdio.h>
int add_two_numbers (int a , int b)
{    
    int sum;
    sum = a+b;
    return sum;
}

Now I want to call this c method from a tcl script. 现在,我想从tcl脚本中调用此c方法。 How should I do it ? 我该怎么办?

You might try compiling your C code and making it a shared library. 您可以尝试编译C代码并使其成为共享库。 Then use the TCL "load" command to load it. 然后使用TCL“ load”命令加载它。 There is some setup work you'll need. 您需要进行一些设置工作。 See the examples in the documentation for the TCL "load" command. 请参阅文档中有关TCL“加载”命令的示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM