Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not build it #5

Open
xbee opened this issue Jun 8, 2018 · 6 comments
Open

Can not build it #5

xbee opened this issue Jun 8, 2018 · 6 comments

Comments

@xbee
Copy link

xbee commented Jun 8, 2018

error info:

# github.com/raff/goble/xpc
xpc_wrapper.c:41:9: warning: implicit declaration of function 'Block_copy' is invalid in C99 [-Wimplicit-function-declaration]
xpc_wrapper.c:41:9: error: invalid block pointer conversion passing 'int' to parameter of type 'xpc_handler_t _Nonnull' (aka 'void (^)(xpc_object_t _Nonnull)')
/usr/include/xpc/connection.h:318:16: note: passing argument to parameter 'handler' here
@raff
Copy link
Owner

raff commented Jun 8, 2018

Can you give more details on how you are building / what's your environment ?

I am currently running MacOS 10.13.5 and XCode 9.4 with Go 1.10.2 and I don't get any error.

@xbee
Copy link
Author

xbee commented Aug 17, 2018

go version go1.10 darwin/amd64
XCode 9.4 
MacOS 10.13.6

@raff
Copy link
Owner

raff commented Aug 17, 2018

Block_copy should be defined in /usr/include/Block.h, included in line 4. Do you have that file and it's there a definition of Block_copy. Something like:

// Create a heap based copy of a Block or simply add a reference to an existing one.
// This must be paired with Block_release to recover memory, even when running
// under Objective-C Garbage Collection.
BLOCK_EXPORT void *_Block_copy(const void *aBlock)
__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);

Do you have the XCode command line tools installed ? Try to follow the instructions here:
https://stackoverflow.com/questions/9353444/how-to-use-install-gcc-on-mac-os-x-10-8-xcode-4-4

@xbee
Copy link
Author

xbee commented Sep 4, 2018

Yes, I have installed Xcode command line tools. And my Block.h have Block_copy's define:

 // Create a heap based copy of a Block or simply add a reference to an existing one.
 // This must be paired with Block_release to recover memory, even when running
 // under Objective-C Garbage Collection.
 BLOCK_EXPORT void *_Block_copy(const void *aBlock)
      __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);

.......

// Type correct macros
 
 #define Block_copy(...) ((__typeof(__VA_ARGS__))_Block_copy((const void *)(__VA_ARGS__)))
 #define Block_release(...) _Block_release((const void *)(__VA_ARGS__))

my gcc environment

> xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

> gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.1.0 (clang-902.0.39.2)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

@xbee
Copy link
Author

xbee commented Sep 6, 2018

I changed code from :

xpc_connection_t XpcConnect(char *service, uintptr_t ctx) {
    dispatch_queue_t queue = dispatch_queue_create(service, 0);
    xpc_connection_t conn = xpc_connection_create_mach_service(service, queue, XPC_CONNECTION_MACH_SERVICE_PRIVILEGED);

    // making a local copy, that should be made "persistent" with the following Block_copy
    //GoInterface ictx = *((GoInterface*)ctx);

    xpc_connection_set_event_handler(conn,
        Block_copy(^(xpc_object_t event) {
            handleXpcEvent(event, ctx); //(void *)&ictx);
        })
    );

    xpc_connection_resume(conn);
    return conn;
}

to next:

xpc_connection_t XpcConnect(char *service, uintptr_t ctx) {
    dispatch_queue_t queue = dispatch_queue_create(service, 0);
    xpc_connection_t conn = xpc_connection_create_mach_service(service, queue, XPC_CONNECTION_MACH_SERVICE_PRIVILEGED);

    // making a local copy, that should be made "persistent" with the following Block_copy
    //GoInterface ictx = *((GoInterface*)ctx);

    xpc_connection_set_event_handler(conn,
       ^(xpc_object_t event) {
            handleXpcEvent(event, ctx); //(void *)&ictx);
        }
    );

    xpc_connection_resume(conn);
    return conn;
}

then it build ok. Just remove Block_copy's wrapped.

@xbee
Copy link
Author

xbee commented Sep 6, 2018

But now when I run examples/basic/scanner/main.go, It will complained:

go run examples/basic/scanner/main.go
2018/09/06 09:39:57 Unhandled event: xpc.Dict{"kCBMsgId":4, "kCBMsgArgs":xpc.Dict{"kCBMsgArgState":5}}
^Csignal: interrupt

And it can not find any bluetooth devices that should be found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants