Skip to content

Add a platform-dependent calling convention alias #8774

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

Closed
ghost opened this issue Aug 26, 2013 · 1 comment · Fixed by #10367
Closed

Add a platform-dependent calling convention alias #8774

ghost opened this issue Aug 26, 2013 · 1 comment · Fixed by #10367

Comments

@ghost
Copy link

ghost commented Aug 26, 2013

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(...);
@nikomatsakis
Copy link
Contributor

You can currently use extern "C stdcall" for this purpose, I believe, but I am amenable to adjust the ABI scheme.

alexcrichton added a commit to alexcrichton/rust that referenced this issue Nov 8, 2013
This adds an other ABI option which allows a custom selection over the target
architecture and OS. The only current candidate for this change is that kernel32
on win32 uses stdcall, but on win64 it uses the cdecl calling convention.
Otherwise everywhere else this is defined as using the Cdecl calling convention.

cc rust-lang#10049
Closes rust-lang#8774
bors added a commit that referenced this issue Nov 9, 2013
This adds an other ABI option which allows a custom selection over the target
architecture and OS. The only current candidate for this change is that kernel32
on win32 uses stdcall, but on win64 it uses the cdecl calling convention.
Otherwise everywhere else this is defined as using the Cdecl calling convention.

cc #10049
Closes #8774
bors added a commit that referenced this issue Nov 9, 2013
This adds an other ABI option which allows a custom selection over the target
architecture and OS. The only current candidate for this change is that kernel32
on win32 uses stdcall, but on win64 it uses the cdecl calling convention.
Otherwise everywhere else this is defined as using the Cdecl calling convention.

cc #10049
Closes #8774
flip1995 pushed a commit to flip1995/rust that referenced this issue Jun 30, 2022
try reading rust-version from Cargo.toml

Cargo.toml can contain a field `rust-version`, that acts like a MSRV of
clippy.toml file: https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field
This will try to read that field and use it, if the clippy.toml config
has no `msrv` entry

changelog: respect `rust-version` from `Cargo.toml`

closes rust-lang#8746
closes rust-lang#7765
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

Successfully merging a pull request may close this issue.

1 participant