Uploaded image for project: 'C++ Driver'
  1. C++ Driver
  2. CXX-81

On Windows, MONGO_API functions should be decorated with __cdecl.

      For example, in Windows, a proper library explicitly specifies the calling convention for each function:

      void __cdecl mongo::connect(char* host)
      

      We are using the default calling convention right now, which is __cdecl. If someone is using __stdcall in their project, they won't be able to use the C++ driver because the calling convention is wrong. Actually, they will be able to compile just fine but run time will not work (and it might not even be obvious what is wrong at first).

      Typically, the __cdecl is hidden inside a macro; we could use MONGO_API:

      #ifdef WIN32
      #define MONGO_API __cdecl
      #else
      #define MONGO_API
      #endif
      

      If we decide to release a DLL or .so library in the future, we could also use the MONGO_API macro to affect the visibility of the API functions using dllexport or gcc attributes.

            Assignee:
            andrew.morrow@mongodb.com Andrew Morrow (Inactive)
            Reporter:
            milkie@mongodb.com Eric Milkie
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: