Tizen 应用程序的入口文件的主要部分是什么?
What are the major parts of a Tizen application's entry file?
由于Tizen仍然不太受欢迎,我找不到Tizen应用程序入口文件的解释。根据下面的示例代码,有人能解释一下Tizen入口文件的特定部分吗(主函数返回值,#ifdef,args…)?
#include <new>
#include "MultipointTouch.h"
using namespace Tizen::Base;
using namespace Tizen::Base::Collection;
#ifdef __cplusplus
extern "C"
{
#endif // __cplusplus
_EXPORT_ int OspMain(int argc, char* pArgv[]);
/**
* The entry function of Tizen C++ application called by the operating system.
*/
int
OspMain(int argc, char* pArgv[])
{
AppLog("Application started.");
ArrayList args;
args.Construct();
for (int i = 0; i < argc; i++)
{
args.Add(*(new (std::nothrow) String(pArgv[i])));
}
result r = Tizen::App::Application::Execute(MultipointTouch::CreateInstance, &args);
TryLog(r == E_SUCCESS, "[%s] Application execution failed", GetErrorMessage(r));
args.RemoveAll(true);
AppLog("Application finished.");
return static_cast<int>(r);
}
#ifdef __cplusplus
}
#endif // __cplusplus
#ifdef __cplusplus
extern "C
不是Tizen特有的。它所做的是"使C++中的函数名具有'C'链接(编译器不会破坏名称),以便客户端C代码可以使用仅包含函数声明的'C'兼容头文件链接到(即使用)您的函数。"(源代码)。
int OspMain(int argc, char* pArgv[])
OspMain
只是Tizen原生应用程序(即应用程序启动时操作系统调用的应用程序中的第一个函数)的入口点,与其他操作系统/框架中的main
或WinMain
非常相似。
- args
App
Execute
方法需要参数作为Strings
的列表。因此,OspMain
函数在调用Execute
方法之前负责构建该列表;从argv
中的每个char*
创建String
,并且将这些Strings
放置在ArrayList
(这是IList
接口的实现)中。
- 返回值
OspMain
的返回类型是int
,但它从Execute
接收的结果代码是result
类型,因此它将result
强制转换为int
。如果你想了解更多关于C++类型转换的信息,这里有很多问题。
最后,我认为作为一名应用程序开发人员,很少有人会关心Entry文件。它是由IDE自动为您创建的,而不是您通常会更改的内容。
相关文章:
- 谁能告诉我,程序中的错误是什么?该程序仅用于获取文件扩展名
- 是什么将程序集转换为实际可执行的材料
- 应用程序仅在安装了 Visual Studio 的 PC 上启动.这种行为的原因可能是什么
- 是什么导致程序在我继续执行另一个功能之前停止
- 有什么理由更喜欢从 IDE 中运行应用程序而不是运行独立的可执行文件?
- 开发C++应用程序,目标服务器有不同的std lib版本,最佳实践是什么
- 将大量数据从C 应用程序传递到SQLServer存储过程的最快方法是什么?
- 一般来说,使用Qt Creator,是什么导致程序在调试模式下编译时正确运行,但在发布模式下崩溃
- Qt for Android:Jni - 不幸的是,应用程序已停止
- 是什么使C++程序仅是 64 位或受机器限制
- 是什么使 C/C++ 程序成为 32/64 位
- 我如何知道一个项目是否是MFC应用程序
- 还原覆盖光标,而不是整个应用程序
- 什么是使应用程序具有CPU和GPU计算后端的最佳方法
- c++ (MFC,不是.net)应用程序的程序集重定向
- 最佳实践是将应用程序核心和gui分开编写
- 为什么LOAD DATA LOCAL INFILE会在CLI中工作,而不是在应用程序中工作
- 其中是MFC应用程序的退出函数
- 将Xaml文本框转换为double,但如何验证用户输入是double,而不是windows 8应用程序的c++中的字符串
- 什么是嵌入应用程序中的最佳HTML呈现引擎