)]}'
{
  "commit": "8f985d239c312aa302386f9245bcafaa5412702a",
  "tree": "669b9f7cebc4955961722f26eda9785b04880cd5",
  "parents": [
    "8069895bbb2a7c183e6e144771bfb4f936c39dff"
  ],
  "author": {
    "name": "Jonathan Marler",
    "email": "johnnymarler@gmail.com",
    "time": "Mon Jul 19 21:42:29 2021 -0600"
  },
  "committer": {
    "name": "LIU Hao",
    "email": "lh_mouse@126.com",
    "time": "Wed Jul 21 16:45:34 2021 +0800"
  },
  "message": "Fix Clang link errors and address of ws2 inline functions\n\nThe following example works with MSVC but will fail using the mingw headers:\n\n    #include \u003cws2tcpip.h\u003e\n    int main(int argc, char **argv) {\n        return (int)\u0026IN6_IS_ADDR_UNSPECIFIED;\n    }\n\nThe reason for this is because MinGW is defining this `IN6_IS_ADDR_UNSPECIFIED` function with\n`extern inline __attribute__((__gnu_inline__))`. A function defined with these attributes will\nNEVER be emitted.  This means you cannot take the address of the function\nand if the compiler does not inline a call to it, then you\u0027ll get a linker error.\n\nIn the Windows SDK in ws2ipdef.h, this function uses the `__inline` attribute\n\nhttps://docs.microsoft.com/en-us/cpp/cpp/inline-functions-cpp?view\u003dmsvc-160\n\n\u003e This keyword tells the compiler that inline expansion is preferred. However, the compiler\n\u003e can create a separate instance of the function (instantiate) and create standard calling\n\u003e linkages instead of inserting the code inline.  Two cases where this behavior can happen are:\n\u003e     * Recursive Functions\n\u003e     * Functions that are referred to through a pointer elsewhere in the translation unit.\n\nNote that this function is not defined in any .lib or .dll file in the Windows sdk and/or runtime,\nso the only way to be able to take the address of it from the example above is if the compiler\nis able to emit the function, or if it\u0027s defined elsewhere.\n\nThe problem here appears to be the inclusion of `__attribute__((__gnu_inline__))` which is what\ntells the compiler NEVER to emit the function definition.  Removing this attribute allows the compiler\nto emit the function which allows its address to be taken, and prevents linker errors if the compiler\ndecides not to inline a call to it.  These linker errors occur often on Clang even when then functions\nare only being called (not even taking the addresses of them) which appears to be caused\nby a decision from Clang to not inline calls to these functions in some cases.\n\nNote that this applies to multiple functions in the ws2 header files.\n\nTo fix this, I\u0027ve modified these ws2 functions to use __mingw_ovr instead of __CRT_INLINE along\nwith adding the \"static\" modifier to the accompanying function declarations.  This should\ncause each translation unit to have their own instance of these functions without\ncausing multiple definition errors.  This is not the exact behavior of MSVC\u0027s `__inline`\nattribute, but it a solution that uses mingw\u0027s existing inline mechanisms without coming up\nwith new ones or modifying existing ones could result in exposing the library to odd corner cases\nfrom obscure platforms/toolchains/stdc implementations.\n\nSigned-off-by: LIU Hao \u003clh_mouse@126.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "d440bbcb8b470f84de58cf31f10b03dfa68d2324",
      "old_mode": 33188,
      "old_path": "mingw-w64-headers/include/ws2ipdef.h",
      "new_id": "6b10db38895724219a9acf4180e6bdd89557d967",
      "new_mode": 33188,
      "new_path": "mingw-w64-headers/include/ws2ipdef.h"
    },
    {
      "type": "modify",
      "old_id": "0a7890bb3b59f005dc20d9a4609295c6b9d3596d",
      "old_mode": 33188,
      "old_path": "mingw-w64-headers/include/ws2tcpip.h",
      "new_id": "cf7d28ba69faf8fd7bac224b13237d53dbd47fb1",
      "new_mode": 33188,
      "new_path": "mingw-w64-headers/include/ws2tcpip.h"
    }
  ]
}
