Skip to content

Commit 1d559c1

Browse files
authored
Add note for invalid nim identifier fixes (#218)
Given ```c void foo() {} void foo_() {} void foo__() {} void __foo() {} void __foo__() {} void foo_bar_() {} void foo_bar() {} void _foo_bar_() {} void foo() {} void foo_() {} void foo__() {} void __foo() {} void __foo__() {} void foo_bar_() {} void foo_bar() {} void _foo_bar_() {} void _____foo___var_asdfasdf_asdf_asdfa_() {} void ______________asss____() {} void ____s_____() {} ``` outputs ```nim proc foo*() = discard proc foo*() = discard proc foo*() = discard proc foo*() = discard proc foo*() = discard proc foo_bar*() = discard proc foo_bar*() = discard proc foo_bar*() = discard proc foo*() = discard proc foo*() = discard proc foo*() = discard proc foo*() = discard proc foo*() = discard proc foo_bar*() = discard proc foo_bar*() = discard proc foo_bar*() = discard proc foo___var_asdfasdf_asdf_asdfa*() = discard proc asss*() = discard proc s*() = discard ``` which seems to be what most users would want
1 parent 9f35924 commit 1d559c1

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

doc/c2nim.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ too, there is no need to quote them:
244244
#mangle ssize_t int
245245
// is short for:
246246
#mangle "'ssize_t'" "int"
247+
248+
To fix leading/trailing/underscore identifiers in C code use `#mangle "^'_'*{@}('_'*$)" "$1"`
247249

248250
``#assumedef`` and ``#assumendef`` directives
249251
----------------------------------------------

0 commit comments

Comments
 (0)