llcppsymg:remove leading underscores

This commit is contained in:
luoliwoshang
2024-10-10 12:21:20 +08:00
parent 60aa74257f
commit 7bd3b29a11
4 changed files with 16 additions and 14 deletions

View File

@@ -132,10 +132,12 @@ func (p *SymbolProcessor) collectFuncInfo(cursor clang.Cursor) {
symbol := cursor.Mangling()
defer symbol.Dispose()
// Remove all leading underscores from C++ symbol names
// On Linux, C++ symbols typically have one leading underscore
// On macOS, C++ symbols may have two leading underscores
// We remove all leading underscores to handle both cases consistently
symbolName := c.GoString(symbol.CStr())
if len(symbolName) >= 1 && symbolName[0] == '_' {
symbolName = symbolName[1:]
}
symbolName = strings.TrimLeft(symbolName, "_")
p.SymbolMap[symbolName] = &SymbolInfo{
GoName: p.genGoName(cursor),
ProtoName: p.genProtoName(cursor),