Skip to content

Add a platform-dependent calling convention alias #8774

Closed
@ghost

Description

Some cross-platform libraries use different calling conventions on different platform. For example, OpenGL uses cdecl on *nix, and stdcall on Windows. Writing wrappers for these libraries is currently troublesome, as it requires special-casing the calling convention in Rust code.

I propose adding an ABI alias called "system" which could be used in extern declarations, in place of "stdcall", "cdecl", etc. It would map to whichever calling convention is default on the specific platform.

Thus one could say, e.g.:

pub type GLDEBUGPROC = extern "system" fn(...);

Rather than:

    #[cfg(target_os = "win32")]
    pub type GLDEBUGPROC = extern "stdcall" fn(...);

    #[cfg(not(target_os = "win32"))]
    pub type GLDEBUGPROC = extern "cdecl" fn(...);

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