File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed
Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ You have already seen an example of how to expose a free C++ function to the Tcl
66
77No matter whether you write an extension module or embed Tcl in a C++ application, the way to expose a free function is alway the same:
88
9- ```
9+ ``` cpp
1010i.def(" tcl_function_name" , cpp_function_name);
1111```
1212
@@ -16,13 +16,13 @@ In the above example, the "tcl_function_name" is a name that will be visible to
1616
1717They do not have to be the same, although this is the usual practice, like in the [ Quick Start] ( quickstart.md ) examples:
1818
19- ```
19+ ``` cpp
2020i.def(" hello" , hello);
2121```
2222
2323Suppose that we want to expose the following C++ function:
2424
25- ```
25+ ``` cpp
2626int sum (int a, int b)
2727{
2828 return a + b;
@@ -31,20 +31,20 @@ int sum(int a, int b)
3131
3232We can define it in the interpreter like this:
3333
34- ```
35- i.def("<span style="font-weight: bold;"> add</span> ", sum);
36- i.def("<span style="font-weight: bold;">+</span> ", sum);
34+ ```cpp
35+ i.def("add", sum);
36+ i.def("+ ", sum);
3737```
3838
3939so that we can call the sum function from Tcl like this:
4040
41- ```
41+ ``` tcl
4242add 3 4
4343```
4444
4545or:
4646
47- ```
47+ ``` tcl
4848+ 3 4
4949```
5050
You can’t perform that action at this time.
0 commit comments