I just started learning node.js and C++ addon. I modified the hello world 
example a little bit to see how it works. Then I found out it runs 
differently in Linux and Windows.

Basically, I added an internal function that used cout to output to the 
console. I know this is not a good practice for the purpose of NW but I 
just wanted to test how it handles these situations. In Linux, the output 
is 

worldtest
yes

but in Windows, it is

yes
worldtest

it seems the Windows output is what I expected it to be. Any ideas what I'm 
missing here?  Thanks!

#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)

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/fa6aaa82-6337-45e7-81e4-2a52796b1179%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to