Hi. What is the best way to get variable value in nim that was previously 
declared in c/cpp code (or inside "emit")? are there a lot of bugs or i'm just 
use it wrongly?

look here for different variants tried by me 
<https://github.com/nim-lang/Nim/issues/16890#issuecomment-1089709161>

one example:
    
    
    proc getint*():cint =
        
        var i {.nodecl}: cint
        {.emit:"int i; i = 14;"}
        return i
    
    echo getint()
    
    
    
    Run

in manual we see: "The nodecl pragma can be applied to almost any symbol 
(variable, proc, type, etc.) and is sometimes useful for interoperability with 
C: It tells Nim that it should not generate a declaration for the symbol in the 
C code. " I assume this pragma should not generate a declaration of any symbol, 
but manual says "ALMOST" any symbol. what does it mean? :)

(Also return and result has strange behaviour too. look at examples at the url 
above.)

Reply via email to