From 325e116b7a893498ce54d2ed381efd1a53aa4489 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Mon, 6 Dec 2021 12:35:56 +0300 Subject: [PATCH] cgen: 4 byte bool flagg for compatibility with some C software --- vlib/v/checker/checker.v | 2 +- vlib/v/gen/c/cheaders.v | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index fc8200d955..47bea7ebf0 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -2913,7 +2913,7 @@ pub fn (mut c Checker) fn_call(mut node ast.CallExpr, mut continue_check &bool) if call_arg.typ != param.typ && (param.typ == ast.voidptr_type || final_param_sym.idx == ast.voidptr_type_idx) && !call_arg.typ.is_any_kind_of_pointer() && func.language == .v - && !call_arg.expr.is_lvalue() && func.name != 'json.encode' { + && !call_arg.expr.is_lvalue() && func.name != 'json.encode' && !c.pref.translated { c.error('expression cannot be passed as `voidptr`', call_arg.expr.position()) } // Handle expected interface diff --git a/vlib/v/gen/c/cheaders.v b/vlib/v/gen/c/cheaders.v index cefd8b6511..2bdb1df04e 100644 --- a/vlib/v/gen/c/cheaders.v +++ b/vlib/v/gen/c/cheaders.v @@ -542,8 +542,11 @@ typedef struct sync__Channel* chan; #ifndef __cplusplus #ifndef bool - //typedef int bool; - typedef byte bool; + #ifdef CUSTOM_DEFINE_4bytebool + typedef int bool; + #else + typedef byte bool; + #endif #define true 1 #define false 0 #endif