Skip to content

Basic documentation code does not compile #119

Closed
@mdenty

Description

@mdenty
use objc::{class, msg_send};
use objc::runtime::{BOOL, Object};

fn main() {
  println!("Hello, world!");
  let cls = class!(NSObject);
  let obj: *mut Object = msg_send![cls, new];
  let hash: usize = msg_send![obj, hash];
  let is_kind: BOOL = msg_send![obj, isKindOfClass:cls];
// Even void methods must have their return type annotated
  let _: () = msg_send![obj, release];
}

The errors are :

error: cannot find macro `sel` in this scope
 --> src/main.rs:7:28
  |
7 |     let obj: *mut Object = msg_send![cls, new];
  |                            ^^^^^^^^^^^^^^^^^^^
  |
  = note: this error originates in the macro `msg_send` (in Nightly builds, run with -Z macro-backtrace for more info)

error: cannot find macro `sel` in this scope
 --> src/main.rs:8:23
  |
8 |     let hash: usize = msg_send![obj, hash];
  |                       ^^^^^^^^^^^^^^^^^^^^
  |
  = note: this error originates in the macro `msg_send` (in Nightly builds, run with -Z macro-backtrace for more info)

error: cannot find macro `sel` in this scope
 --> src/main.rs:9:25
  |
9 |     let is_kind: BOOL = msg_send![obj, isKindOfClass:cls];
  |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: this error originates in the macro `msg_send` (in Nightly builds, run with -Z macro-backtrace for more info)

error: cannot find macro `sel` in this scope
  --> src/main.rs:11:17
   |
11 |     let _: () = msg_send![obj, release];
   |                 ^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the macro `msg_send` (in Nightly builds, run with -Z macro-backtrace for more info)

error: could not compile `objc-test` due to 4 previous errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions