From 6d12f57d1441a32a3aa13c94f4fde509c5b35c07 Mon Sep 17 00:00:00 2001 From: Shib Date: Wed, 13 Apr 2022 12:01:55 +0200 Subject: [PATCH] Add (gen > c) -> Added callconv attribute for function --- vlib/v/gen/c/fn.v | 5 +++++ vlib/v/parser/fn.v | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/vlib/v/gen/c/fn.v b/vlib/v/gen/c/fn.v index e55383c288..520267b213 100644 --- a/vlib/v/gen/c/fn.v +++ b/vlib/v/gen/c/fn.v @@ -2153,6 +2153,11 @@ fn (mut g Gen) write_fn_attrs(attrs []ast.Attr) string { '_fastcall' { fn_attrs += '__fastcall ' } + "callconv" { + if attr.has_arg { + fn_attrs += '__$attr.arg ' + } + } 'console' { g.force_main_console = true } diff --git a/vlib/v/parser/fn.v b/vlib/v/parser/fn.v index e956f2e116..d00fe81195 100644 --- a/vlib/v/parser/fn.v +++ b/vlib/v/parser/fn.v @@ -197,6 +197,19 @@ fn (mut p Parser) fn_decl() ast.FnDecl { 'c2v_variadic' { is_c2v_variadic = true } 'use_new' { is_ctor_new = true } 'markused' { is_markused = true } + "windows_stdcall" { + p.warn_with_pos('windows_stdcall has been deprecated, it will be an error soon', p.tok.pos()) + } + "_fastcall" { + p.warn_with_pos('_fastcall has been deprecated, it will be an error soon', p.tok.pos()) + } + "callconv" { + if fna.has_arg { + if fna.arg !in ['stdcall', 'fastcall', 'cdecl'] { + p.error_with_pos('unsupported calling convention, supported are stdcall, fastcall and cdecl', p.tok.pos()) + } + } + } else {} } }