{"id":131,"date":"2015-06-24T15:15:54","date_gmt":"2015-06-24T07:15:54","guid":{"rendered":"http:\/\/magicalbits.net\/?p=131"},"modified":"2015-06-24T15:15:54","modified_gmt":"2015-06-24T07:15:54","slug":"c-callbacks-in-swift","status":"publish","type":"post","link":"https:\/\/magicalbits.net\/?p=131","title":{"rendered":"C Callbacks in Swift"},"content":{"rendered":"<blockquote><p>With Swift 2, it is now possible to do this fully natively in Swift. C function pointers are imported into Swift as closures. You can pass any Swift closure or function with matching parameters to code that expects a C function pointer \u2013 with one massive caveat: unlike closures, C function pointers don\u2019t have the concept of capturing state. As a result, the compiler will only allow Swift closures that do not capture any outside state to be bridged to a C function pointer. Swift uses the new @convention(c) notation to indicate this calling convention.<\/p><\/blockquote>\n<p>Source: <em><a href=\"http:\/\/oleb.net\/blog\/2015\/06\/c-callbacks-in-swift\/\">C Callbacks in Swift \u2013 Ole Begemann<\/a><\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>With Swift 2, it is now possible to do this fully natively in Swift. C function pointers are imported into Swift as closures. You can pass any Swift closure or function with matching parameters to code that expects a C function pointer \u2013 with one massive caveat: unlike closures, C function pointers don\u2019t have the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ep_exclude_from_search":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-131","post","type-post","status-publish","format-standard","hentry","category-uncategorised"],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/magicalbits.net\/index.php?rest_route=\/wp\/v2\/posts\/131","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/magicalbits.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/magicalbits.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/magicalbits.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/magicalbits.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=131"}],"version-history":[{"count":1,"href":"https:\/\/magicalbits.net\/index.php?rest_route=\/wp\/v2\/posts\/131\/revisions"}],"predecessor-version":[{"id":132,"href":"https:\/\/magicalbits.net\/index.php?rest_route=\/wp\/v2\/posts\/131\/revisions\/132"}],"wp:attachment":[{"href":"https:\/\/magicalbits.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/magicalbits.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/magicalbits.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}