| 1 | module library |
| 2 | |
| 3 | // add_1 is exported with the C name `add_1`. |
| 4 | // It can be called by external programs, when the module is compiled |
| 5 | // as a shared library. |
| 6 | // It is exported, because the function is declared as public with `pub`. |
| 7 | // The exported C name is `add_1`, because of the export: tag. |
| 8 | // (Normally, the exported name is a V mangled version based on the module |
| 9 | // name followed by __, followed by the fn name, i.e. it would have been |
| 10 | // `library__add_1`, if not for the export: tag). |
| 11 | @[export: 'add_1'] |
| 12 | pub fn add_1(x int, y int) int { |
| 13 | return my_private_function(x + y) |
| 14 | } |
| 15 | |
| 16 | // this function is not exported and will not be visible to external programs. |
| 17 | fn my_private_function(x int) int { |
| 18 | return 1 + x |
| 19 | } |
| 20 | |