0

I want to use an std::vector for an app that I'm creating with Tizen and I can't find the right library to include to make my std::vector be recognized... I have a syntax error... Is there an equivalent to std::vector specific to Tizen? I searched the web but I didn't find anything...

I tried #include <vector> Tizen doesn't recognize it, that's what my problem is because in "normal" C++ it works fine. Only I'm using Tizen with Tizen IDE (Eclipse plug-in) and it doesn't recognize the library so I'm wondering which library I need to include instead (I got a fatal error: file not found when I use the include I mentioned).

I can't post images so here's a transcript of the error message:

type name requires a specifier or qualifier
syntax error
expected expression"

All of which regarding this line:

std::vector<int> vect;

OK, I found my answer. It seems Tizen is using C and not C++... I didn't see it because some libraries I sometimes use when I code in C++ were included like they should. Anyway I'm just gonna have to find the C equivalent of vector now and my problem will be solved.

4

3 回答 3

1

你说:我搜索了网络,但我没有找到任何东西......

谷歌“std::vector”第一个命中是

http://en.cppreference.com/w/cpp/container/vector 说:

在标题中定义<vector>

所以答案是:学会使用谷歌。

于 2015-04-02T14:13:42.733 回答
0

https://developer.tizen.org/dev-guide/2.2.0/

Tizen C++ 应用程序支持基于标准 C++ ANSI ISO 14882 2003 的 C++,其中包括标准模板库 (STL)。这有助于开发人员以最小的努力将基于预先存在的基于标准库的应用程序迁移到 Tizen 平台。

更具体地说,Tizen 支持完整的 libstdc++v3 集,包括标准 C++ ANSI ISO 14882 2003 和整个标准模板库 ( http://www.sgi.com/tech/stl/ )中指定的标准 C++ 函数。

这些方法可以通过以标准方式包含相关头文件来使用,例如“ #include <stdio>”。对标准 C++ 库的支持扩展到完整的 libstdc++v3 模块、命名空间和类集。有关详细信息,请参阅此网站

备注:Tizen 不支持基于语言环境的功能。

所以#include <vector>应该可以正常工作。

既然你说你不能包含任何C++ 头文件,我怀疑问题是编译器将你的代码编译为 C 而不是 C++。确认您的文件具有 .cpp 扩展名,并在项目中查看文件的属性以确认 IDE 将文件视为 C++。(我不知道那个设置在哪里,我没有 Eclipse)。 此链接说要删除您的项目并创建一个 C++ 项目而不是 C 项目,然后重新导入您的文件。 此链接说您可以设置“文件类型”,但也暗示它不太有效。

于 2015-04-02T16:26:52.943 回答
0

我认为错误的答案被接受了……线索在 OP 使用的标签中。

Tizen Studio 使用的编译器根据文件扩展名确定源文件或头文件是 C 还是 C++。所以如果你的头文件是 .h 并且你包含 <vector> 那么编译器会抱怨因为没有向量的 C 等效库。

如果您将标头重命名为 .hpp,或将源重命名为 .cpp,然后重新编译,那么它将编译而不会出错。

于 2019-10-30T23:41:17.270 回答