Search code examples
c++macosdllframeworksentry-point

How to define an optional entry point into custom Mac OS X framework / dynamic library?


In Windows there is a DllMain and DLL_PROCESS_ATTACH / DLL_PROCESS_DETACH flags, which allow to initialize / free resources after DLL is attached to a process... So how can I specify an entry point in case of OS X? As always, I can't find anything useful in Apple documentation :(


Solution

  • Wouldn't that work?

    __attribute__((constructor)) void DllMain() 
    { 
      // code
    }