javascript - node.js C++ addon runing differently in Linux and Windows -


i started learning node.js , particularly c++ addon. modified hello world example little bit see how works. found out runs differently in linux , windows.

basically, added internal function used cout output console. in linux, output is

worldtest yes 

but in windows, is

yes worldtest 

basically orders of outputs different. seems windows output expected be. ideas i'm missing here? thanks!

hello.cc:

#include <node.h> #include <v8.h> #include <string> #include <iostream>   using namespace v8; using namespace std; string changestring(string tmp);  void method(const v8::functioncallbackinfo<value>& args) {   isolate* isolate = isolate::getcurrent();   handlescope scope(isolate);   string tmp=changestring("world");   const char * c=tmp.c_str();   args.getreturnvalue().set(string::newfromutf8(isolate, c));    }  void init(handle<object> exports) {   isolate* isolate = isolate::getcurrent();   exports->set(string::newfromutf8(isolate, "hello"),       functiontemplate::new(isolate, method)->getfunction()); }  string changestring(string tmp) {     cout<<"yes\n";     return (tmp+"test\n");     }  node_module(hello, init) 

hello.js

var addon = require('bindings')('hello');  console.log(addon.hello()); // 'world' 


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -