Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Could not find class in com #231

@Rike-cz

Description

@Rike-cz

I really do not know, why is com::interfaces! macro accepted and following macro com::class! is unknown. (Rust v. 1.56.1)

   Compiling proc-macro2 v1.0.32
   Compiling unicode-xid v0.2.2
   Compiling syn v1.0.81
   Compiling quote v1.0.10
   Compiling com_macros_support v0.6.0
   Compiling com_macros v0.6.0
   Compiling com v0.6.0
   Compiling vfp v0.1.0 (C:\apps\rust\vfp)
error[E0433]: failed to resolve: could not find `class` in `com`
  --> src\lib.rs:23:6
   |
23 | com::class! {
   |      ^^^^^ could not find `class` in `com`

error: could not compile `vfp` due to previous error; 1 warning emitted

Whole lib.rs file taken from docs:

use com::sys::{HRESULT, IID, NOERROR};
use core::ffi::c_void;

com::interfaces! {
    #[uuid("00000000-0000-0000-C000-000000000046")]
    pub unsafe interface IUnknown {
        fn QueryInterface(
            &self,
            riid: *const IID,
            ppv: *mut *mut c_void
        ) -> HRESULT;
        fn AddRef(&self) -> u32;
        fn Release(&self) -> u32;
    }

    #[uuid("EFF8970E-C50F-45E0-9284-291CE5A6F771")]
    pub unsafe interface IAnimal: IUnknown {
        fn Eat(&self) -> HRESULT;
    }
}

com::class! {
    pub class BritishShortHairCat: ICat(IAnimal), IDomesticAnimal(IAnimal) {
        num_owners: u32,
    }

    impl IDomesticAnimal for BritishShortHairCat {
        fn Train(&self) -> HRESULT {
            println!("Training...");
            NOERROR
        }
    }

    impl ICat for BritishShortHairCat {
        fn IgnoreHumans(&self) -> HRESULT {
            println!("Ignoring Humans...");
            NOERROR
        }
    }

    impl IAnimal for BritishShortHairCat {
        fn Eat(&self) -> HRESULT {
            println!("Eating...");
            NOERROR
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions