Subj : How to return JSString from a C Function? To : netscape.public.mozilla.jseng From : "F. Lucto" Date : Thu Aug 28 2003 06:48 pm given a javascript like this: function a() { myString = MyCFunction(); return myString } What does a C function have to look like in order to return a JSString rather than a JSBool? I tried declaring the C fucntion like this: JSString * MyCFunction(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { //for sake of argument jsval vtmp = STRING_TO_JSVAL("my string"); return JSString * jss = JS_ValueToString(cx,vtmp); } but the compiler doesn't like that and says: error C2664: 'JS_DefineFunction' : cannot convert parameter 4 from 'struct JSString *(struct JSContext *,struct JSObject *,unsigned int,long *,long *)' to 'int (__cdecl *)(struct JSContext *,struct JSO bject *,unsigned int,long *,long *)' I take this to mean that any function defined with JS_DefineFunction must be of type JSBool, but I can't seem to access the rval that contains the string I want from inside the JavaScript (when I implement the function as JSBool and put the string in the rval) Any suggestions? I'm sure it's my vast lack of experience with JavaScript that's in my way, as usual. Thanks. .