Is it possible to suppress standard lib and dlang symbols in dylib (macos)

David dangermouseb at forwarding.cc
Thu Mar 11 08:34:48 UTC 2021


I thought it would be fun to convert some old C++/C quant utils 
to D. I'm starting with a simple library that I call from vba in 
Excel on macos:


module xlutils;

import core.stdc.string : strlen, strcpy;
//import std.conv : to;
//import std.string : toStringz;
import core.stdc.stdlib : malloc, free;

extern (C) double addDD_D(double a, double b) {return a + b;}
...


which results in:

nm -gU libxlutils.dylib
0000000000003f10 S __D7xlutils12__ModuleInfoZ
0000000000003e44 T _addDD_D
0000000000003ebc T _addrC
0000000000003e84 T _freeP
0000000000003e9c T _strcpyCC
0000000000003e6c T _strlenC_L


If I import `to` and `toStringz` I get more symbols than will fit 
in my shell output. E.g.

00000000000318bc T 
__D2rt5minfo11ModuleGroup9sortCtorsMFAyaZ8findDepsMFmPmZ9__lambda5MFNbNiQBjZv
0000000000031534 T 
__D2rt5minfo11ModuleGroup9sortCtorsMFAyaZ8findDepsMFmPmZb
0000000000030dcc T __D2rt5minfo11ModuleGroup9sortCtorsMFAyaZv
0000000000031db4 T __D2rt5minfo11ModuleGroup9sortCtorsMFZv
0000000000048ef0 S __D2rt5minfo12__ModuleInfoZ
00000000000327e4 T 
__D2rt5minfo16rt_moduleTlsCtorUZ14__foreachbody1MFKSQBx19sections_osx_x86_6412SectionGroupZi
...
00000000000183ac T _thread_resumeAll
0000000000018660 T _thread_scanAll
0000000000018480 T _thread_scanAllType
0000000000019658 T _thread_suspendAll


Is there a way of not exposing the symbols that aren't mine? - I 
only need a simple C interface.

Thx

David







More information about the Digitalmars-d-learn mailing list