{"action":"opened","issue":{"url":"https://api.github.com/repos/basil00/Divert/issues/121","repository_url":"https://api.github.com/repos/basil00/Divert","labels_url":"https://api.github.com/repos/basil00/Divert/issues/121/labels{/name}","comments_url":"https://api.github.com/repos/basil00/Divert/issues/121/comments","events_url":"https://api.github.com/repos/basil00/Divert/issues/121/events","html_url":"https://github.com/basil00/Divert/issues/121","id":296992047,"number":121,"title":"[Feature Request] static windivert","user":{"login":"sgeto","id":8343121,"avatar_url":"https://avatars1.githubusercontent.com/u/8343121?v=4","gravatar_id":"","url":"https://api.github.com/users/sgeto","html_url":"https://github.com/sgeto","followers_url":"https://api.github.com/users/sgeto/followers","following_url":"https://api.github.com/users/sgeto/following{/other_user}","gists_url":"https://api.github.com/users/sgeto/gists{/gist_id}","starred_url":"https://api.github.com/users/sgeto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgeto/subscriptions","organizations_url":"https://api.github.com/users/sgeto/orgs","repos_url":"https://api.github.com/users/sgeto/repos","events_url":"https://api.github.com/users/sgeto/events{/privacy}","received_events_url":"https://api.github.com/users/sgeto/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-02-14T06:43:52Z","updated_at":"2018-02-14T06:43:52Z","closed_at":null,"author_association":"NONE","body":"In include/windivert.h, if you were to change\r\n\r\n```\r\n#ifndef WINDIVERTEXPORT\r\n#define WINDIVERTEXPORT     __declspec(dllimport)\r\n#endif      /* WINDIVERTEXPORT */\r\n```\r\n\r\nto\r\n\r\n```\r\n#ifndef WINDIVERTEXPORT\r\n#define WINDIVERTEXPORT     __declspec(dllimport)\r\n#else\r\n#define WINDIVERTEXPORT\r\n#endif      /* WINDIVERTEXPORT */\r\n```\r\n\r\nThen simply adding `-DWINDIVERTEXPORTS` to one's compile flags should do the trick.\r\n\r\nThis, however, introduces two \"problem\":\r\n\r\n1. There would always be this harmless but annoying redefinition warning since `WINDIVERTEXPORTS` is being defined twice (on the command line and in windivert.h)\r\n\r\n2. `WINDIVERTEXPORTS` isn't a very suitable name to instruct static linkage. It would probably be much clearer to define something like `WINDIVERTSTATIC` instead:\r\n\r\n```\r\n#ifdef WINDIVERTSTATIC\r\n#define WINDIVERTEXPORT\r\n#else\r\n#define WINDIVERTEXPORT     __declspec(dllimport)\r\n#endif      /* WINDIVERTSTATIC */\r\n```\r\n\r\nI also inverted the order to make this change more backward compatible (having to explicitly define static will break builds).\r\n\r\nBut it doesn't have to stop there:\r\nWindivert currently uses a def file for exports, and `WINDIVERTEXPORT`  resolves to `__declspec(dllimport) ` which is kind of weird. Also, the speed/performance of the DLL can be increased by dropping the def file in favor of __declspec(dllexport)  for which the `WINDIVERTEXPORT` macro can then be used:\r\n\r\n```\r\n#ifdef WINDIVERTSTATIC\r\n/* windivert is being built or linked statically */\r\n#define WINDIVERTAPI\r\n#elif WINDIVERTEXPORT\r\n/* windivert is being built dynamically */\r\n#define WINDIVERTAPI  __declspec(dllexport\r\n#else\r\n/* windivert is being linked dynamically */\r\n#define WINDIVERTAPI     __declspec(dllimport)\r\n#endif      /* WINDIVERTAPI */\r\n```\r\n\r\nAnd then also rename all instances of `WINDIVERTEXPORT` to `WINDIVERTAPI`"}}
{"actor":{"display_login":"sgeto"}}