{"action":"created","issue":{"url":"https://api.github.com/repos/arduino/Arduino/issues/3896","labels_url":"https://api.github.com/repos/arduino/Arduino/issues/3896/labels{/name}","comments_url":"https://api.github.com/repos/arduino/Arduino/issues/3896/comments","events_url":"https://api.github.com/repos/arduino/Arduino/issues/3896/events","html_url":"https://github.com/arduino/Arduino/pull/3896","id":108922390,"number":3896,"title":"[PluggableHID] 2nd round of API improvement (WIP)","user":{"login":"cmaglie","id":423515,"avatar_url":"https://avatars.githubusercontent.com/u/423515?v=3","gravatar_id":"","url":"https://api.github.com/users/cmaglie","html_url":"https://github.com/cmaglie","followers_url":"https://api.github.com/users/cmaglie/followers","following_url":"https://api.github.com/users/cmaglie/following{/other_user}","gists_url":"https://api.github.com/users/cmaglie/gists{/gist_id}","starred_url":"https://api.github.com/users/cmaglie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmaglie/subscriptions","organizations_url":"https://api.github.com/users/cmaglie/orgs","repos_url":"https://api.github.com/users/cmaglie/repos","events_url":"https://api.github.com/users/cmaglie/events{/privacy}","received_events_url":"https://api.github.com/users/cmaglie/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/arduino/Arduino/labels/Component:%20USB%20Device","name":"Component: USB Device","color":"009800"},{"url":"https://api.github.com/repos/arduino/Arduino/labels/Library:%20HID","name":"Library: HID","color":"000000"},{"url":"https://api.github.com/repos/arduino/Arduino/labels/Type:%20Improvement","name":"Type: Improvement","color":"0052cc"}],"state":"open","locked":false,"assignee":{"login":"cmaglie","id":423515,"avatar_url":"https://avatars.githubusercontent.com/u/423515?v=3","gravatar_id":"","url":"https://api.github.com/users/cmaglie","html_url":"https://github.com/cmaglie","followers_url":"https://api.github.com/users/cmaglie/followers","following_url":"https://api.github.com/users/cmaglie/following{/other_user}","gists_url":"https://api.github.com/users/cmaglie/gists{/gist_id}","starred_url":"https://api.github.com/users/cmaglie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmaglie/subscriptions","organizations_url":"https://api.github.com/users/cmaglie/orgs","repos_url":"https://api.github.com/users/cmaglie/repos","events_url":"https://api.github.com/users/cmaglie/events{/privacy}","received_events_url":"https://api.github.com/users/cmaglie/received_events","type":"User","site_admin":false},"milestone":null,"comments":22,"created_at":"2015-09-29T17:53:14Z","updated_at":"2015-10-01T14:59:56Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/arduino/Arduino/pulls/3896","html_url":"https://github.com/arduino/Arduino/pull/3896","diff_url":"https://github.com/arduino/Arduino/pull/3896.diff","patch_url":"https://github.com/arduino/Arduino/pull/3896.patch"},"body":"This is a follow up to #3840, an attempt to make the PluggableHID API more flexible before the release.\r\n\r\n@NicoHood, please, try to find 10 minutes to look at the commits one at a time. From what I can see they \"match\" your latest attempts very closely.\r\n\r\nThis is implemented on AVR only for now (SAM and SAMD will follow).\r\n"},"comment":{"url":"https://api.github.com/repos/arduino/Arduino/issues/comments/144753867","html_url":"https://github.com/arduino/Arduino/pull/3896#issuecomment-144753867","issue_url":"https://api.github.com/repos/arduino/Arduino/issues/3896","id":144753867,"user":{"login":"cmaglie","id":423515,"avatar_url":"https://avatars.githubusercontent.com/u/423515?v=3","gravatar_id":"","url":"https://api.github.com/users/cmaglie","html_url":"https://github.com/cmaglie","followers_url":"https://api.github.com/users/cmaglie/followers","following_url":"https://api.github.com/users/cmaglie/following{/other_user}","gists_url":"https://api.github.com/users/cmaglie/gists{/gist_id}","starred_url":"https://api.github.com/users/cmaglie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmaglie/subscriptions","organizations_url":"https://api.github.com/users/cmaglie/orgs","repos_url":"https://api.github.com/users/cmaglie/repos","events_url":"https://api.github.com/users/cmaglie/events{/privacy}","received_events_url":"https://api.github.com/users/cmaglie/received_events","type":"User","site_admin":false},"created_at":"2015-10-01T14:59:56Z","updated_at":"2015-10-01T14:59:56Z","body":"omg @matthijskooijman you're right, we hit exactly in the static initialization order fiasco, totally missed that :-(\r\n\r\nhttps://isocpp.org/wiki/faq/ctors#static-init-order\r\n\r\nThe FAQ propose also doing the initialization using lazy construction through an helper function, for example:\r\n\r\n```C++\r\nHID_& HID()\r\n{\r\n  static HID_* obj = new HID_();\r\n  return *obj;\r\n}\r\n```\r\n\r\nand replace every occurrence of HID with the call to HID() so:\r\n\r\n```C++\r\nHID.SendReport(.....);\r\n```\r\n\r\nbecomes\r\n\r\n```C++\r\nHID().SendReport(....);\r\n```\r\n\r\nVery ugly :-( don't know if there are other easier solutions.\r\n"}}