Index: tcc4tcl.tcl ================================================================== --- tcc4tcl.tcl +++ tcc4tcl.tcl @@ -176,10 +176,20 @@ if {[llength $adefs_c] == 0} { set adefs_c "void" } else { set adefs_c [join $adefs_c {, }] } + + # Determine actual C return type: + switch -- $rtype { + "ok" { + set rtype_c "int" + } + default { + set rtype_c $rtype + } + } # Determine how to return in failure if {$rtype != "void"} { if {[info exists returnErrorValue]} { set return_failure "return(${returnErrorValue})" @@ -202,11 +212,11 @@ } else { set return_failure "return" } # Define the C function - _ccode $handle "$rtype $cname\($adefs_c) \{" + _ccode $handle "$rtype_c $cname\($adefs_c) \{" ## Define the Tcl return value checking variable _ccode $handle " int tclrv;" ## If the interpreters return value is relevant, create a variable to store it @@ -214,11 +224,11 @@ _ccode $handle " Tcl_Obj *rv_interp;" } ## If we are returning a value, declare a variable for that if {$rtype != "void"} { - _ccode $handle " $rtype rv;" + _ccode $handle " $rtype_c rv;" } ## If we need to create a new interpreter, do so if {$newInterp} { set interp_name "ip" @@ -318,11 +328,11 @@ } switch -- $rtype { void { } ok { - _ccode $handle " rv = 0;" + _ccode $handle " rv = TCL_OK;" } int { _ccode $handle " if (Tcl_GetIntFromObj(ip, rv_interp, &rv) != TCL_OK) $return_failure;" } long { Index: test.tcl ================================================================== --- test.tcl +++ test.tcl @@ -169,7 +169,13 @@ $handle go puts [callToTcl1 3] set handle [tcc4tcl::new] $handle proc callToTclBinary {char* blob int blob_Length} ok { - puts "Blob: $blob" + puts "Blob: $blob ([string length $blob])" +} +$handle cproc callToTclBinaryWrapper {} void { + callToTclBinary("test\x00test", 9); } +puts [$handle code] +$handle go +callToTclBinaryWrapper