Skip to content

Commit 708142c

Browse files
Add best practice for avoiding native symbol name collisions (dotnet#9484)
* Add best practice for avoiding native symbol name collisions * Update xml/System.Runtime.InteropServices/UnmanagedCallersOnlyAttribute.xml Co-authored-by: Aaron Robinson <[email protected]> --------- Co-authored-by: Aaron Robinson <[email protected]>
1 parent b5d5580 commit 708142c

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

xml/System.Runtime.InteropServices/UnmanagedCallersOnlyAttribute.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ Supplied types must be from the official <xref:System.Runtime.CompilerServices>
138138
## Remarks
139139
140140
The export name must be a valid identifier for a native symbol on the target platform. The identifier must not conflict with system-provided native identifiers (for example, names of methods in the C standard library, or POSIX/Win32 API names).
141+
Using a prefix for symbols is a common way to avoid name collisions of native symbols. For example, you can name the exported functions as `mylibrary_free`, `mylibrary_isdigit` and `mylibrary_copy` to avoid name collisions.
141142
142143
Target-dependent name mangling will be performed on the symbol name such as prepending or appending `_` or `@` characters to distinguish calling conventions on x86 Windows.
143144

0 commit comments

Comments
 (0)