Has anyone successfully managed to import `os_log`...
# kotlin-native
s
Has anyone successfully managed to import
os_log
functions in iOS/macOS ? In ObjC it comes from a macro declared in
iPhoneSimulator.sdk/usr/include/os/log.h
but as such it doesn't seem to be visible in K/N
o
general practise is that you could reexport any macro-definition from .def file, as a function, like https://github.com/JetBrains/kotlin-native/blob/27a31167e6ea79b69a2c1c8bce171b0b2348cbe5/platformLibs/src/platform/linux/posix.def#L63
however, some macro definitions can be currently seen by interop bridge by default
s
Thank you @olonho :) But why isn’t it the case of os_log? Other functions of os.log library are indeed already visible. Should I file a bug?
o
os_log
and
os_log_with_type
it relies upon is declared as rather complex macro definition
Copy code
#define os_log_with_type(log, type, format, ...) __extension__({ \
    os_log_t _log_tmp = (log); \
    os_log_type_t _type_tmp = (type); \
    if (os_log_type_enabled(_log_tmp, _type_tmp)) { \
        OS_LOG_CALL_WITH_FORMAT(_os_log_impl, \
                (&__dso_handle, _log_tmp, _type_tmp), format, ##__VA_ARGS__); \
    } \
})
so interop tool cannot cope with it. However, adding C wrapper shall help in your case.