如何在javascript中编写代码以使用C中的函数 [英] how do I write code in javascript to use a function in C

查看:52
本文介绍了如何在javascript中编写代码以使用C中的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我想在javascript代码中使用它时,假设我在C中有一些简单的函数,如下所示

Suppose that I have some simple function in C like the following when I want to use it in javascript code

展开 | 选择 | 换行 | 行号

推荐答案

你不能在JavaScript中使用C / C ++函数。


主要原因:C ++ =>在应用程序中编译,JavaScript =>在浏览器的沙盒中解析。


创建JavaScript你只需要一个文本编辑器(虽然标签突出显示,所有的花里胡哨使得它更舒服)编写和简单( X)主持/执行的HTML页面。


顺便说一句。是什么让你认为JavaScript无法完成复杂的任务,或者只是重新使用已经编写的代码的冲动?


* - 如果你想在浏览器中运行JS ,其他主机应用程序可能会提供您可以使用的API。


PS。
you can?t* use C/C++ functions in JavaScript.

main reason: C++ => compiled in an application, JavaScript => parsed in the browser?s sandbox.

to create JavaScript you only need a text editor (although tag highlighting and all the bells and whistles make it more comfortable) to write and a simple (X)HTML page to host/execute.

btw. what makes you think JavaScript is unable to do complex tasks, or is it just the urge to re-use already written code?

* - if you want to run the JS in the browser, other host applications may provide an API you can use.

PS.
展开 | 选择 | Wrap | 行号


其中一个原因是我想重新使用已编写的代码,但这不是唯一的原因。

C也更快,人们告诉我,我可以使用像

server.createobject和dll这样的东西,但我不确定我需要做什么。


一些一步一步的说明可以明显帮助我。


如果我能看到一步一步的简单示例说明它可以帮助我使用我已经拥有代码的其他功能。


Uri
one of the reasons is that I want to re-use already written code but it is not the only reason.

C is also faster and people told me that I can use something like
server.createobject and dll but I am not sure exactly what I need to do for it.

Some step by step instructions can clearly help me.

If I can see step by step instructions for a simple example it can help me to use other functions that I already have code for them.

Uri


@urib


当然是更快,编译代码总是(与解析代码相比)。

?除非你有系统互动

@urib


之前从未听说过。无论如何,JavaScript无法访问本地文件。

@urib


我已提及这不可能吗?
@urib
of course it?s faster, compiled code always is (compared to parsed code).
? unless you have system interactions

@urib
never heard of that before. anyway, JavaScript does not have access to local files.

@urib
did I already mention that it?s not possible?


这篇关于如何在javascript中编写代码以使用C中的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆