Skip to content

#[derive(...)] for 'extern fn' types #23403

Closed
@KyleMayes

Description

@KyleMayes

When trying to autogenerate Rust bindings from C headers, I came across the problem that I cannot use either #[derive(Clone)] or #[derive(Debug)] with extern fn(...) types.

I would think that the default derivation for extern fn(...) types would be the same as raw pointers. Is there something more complex about extern fn(...) types that prevents them being copied and printed as pointers?

#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct FfiStruct {
    pub pointer: *mut i32, // fine
    pub function_pointer: extern fn(), // nope
}

fn main() {
}

Meta

rustc 1.0.0-nightly (3e4be02b8 2015-03-13) (built 2015-03-14)
binary: rustc
commit-hash: 3e4be02b80a3dd27bce20870958fe0aef7e7336d
commit-date: 2015-03-13
build-date: 2015-03-14
host: x86_64-unknown-linux-gnu
release: 1.0.0-nightly

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