Hello function
在每一个生成的扩展程序的可执行代码中,均包含入口函数,即 hello function。Agine 可执行文件加载器通过定位其输出表中的 hello function 来确定其入口。
hello function 类似与 main function,当一个扩展程序进程被创建完成后,Agine 会自动调用 hello function。开发者应在 hello function 下编写其扩展程序的初始化代码,如添加请求响应方法、加载必要的资源文件等。
以下是对 hello function 的声明:
int hello();
同时,任何扩展程序应在 Project 中包含 h.studio 头文件,在该头文件中定义了基于 Agine 扩展程序开发的必要 code 与 function。其 code 可以在 SDK 的 include 目录中找到。
hello function 会被当前扩展程序进程主线程所调用,所以当 hello function 执行完成并返回后主线程即会退出,因而扩展程序进程也会被终止运行。
C++ code:
#include <h.studio>
int hello() {
// Write the initialization code here...
return 0;
}