JavaScript and C – How to Call a JavaScript Function from C

bindingcjavascriptlanguages

I'd like to find a way to call Javascript functions from C. Are there any language bindings available for this purpose? I'm trying to make a library of Javascript functions accessible from C. (Something like a C -> Javascript foreign function interface would be suitable for this purpose, but I haven't been able to find one so far.)

Best Answer

There's quite a few Javascript engines you can use. Which one makes most sense will largely depend on your specific platform/target environments/needs.

There's the V8 javascript engine that powers Chrome, and Firefox's SpiderMonkey.

If Windows-only would suffice, you can use Active Scripting (IActiveScript site and other interfaces). A number of my Windows applications do this.

If QT, I believe they have their own JavaScript classes that can be accessed.

Thats not an exhaustive list, I'm sure there are others. But that should get your search started.

Related Topic