• Fri 2018.09.21

    Using code snippet under heading 'Adding code to a module'

    ref: http://www.espruino.com/InlineC

    Snippet works when using in a monolithic file between var exports={};
    output is

    print( c.lookup(3) );
    =44
    

    as expected

    Verifying

    'Adding inline C to a module is easy - just write the Inline C as you would normally do, then export it:'


    But, when deployed to GitHub

    >Uncaught Error: Function "compiledC" not found!
     at line 8 col 11
    var c = E.compiledC(`
    
    

    Code file

    >var c = require("https://github.com/sleuthware/E­spruinoDocs/blob/master/modules/moduleIn­lineCTest.js");
    
    print( c.lookup(3) );
    

    Deployed module

    var c = E.compiledC(`
    // double lookup(int)
    
    double lut[8] = {
     41,42,43,44,45,46,47,48
    };
    double lookup(unsigned int x)
    {
      return lut[x&7];
    }
    `);
    
    exports = c;
    



    EDIT Sun 2018.09.23
    From #4 below

    'From where is the > sign come in'

    Forum post edit error - quote button slip instead of code button - the fix - for right editor pane

    var c = require("https://github.com/sleuthware/E­spruinoDocs/blob/master/modules/moduleIn­lineCTest.js");
    
    print( c.lookup(3) );
    
About

Avatar for Robin @Robin started