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.

Eduard Florinescu
  • 16,747
  • 28
  • 113
  • 179
Yaoming
  • 79
  • 1
  • 6
  • try `#include ` – Kasim Rangwala Apr 02 '15 at 13:33
  • 3
    When you ask this type of question, please show the include you tried and the error message you received. Otherwise you are asking people to guess what the problem is. The "Help" link up at the top of the screen gets you to lots more helpful information about asking good questions on Stack Overflow. – Dale Wilson Apr 02 '15 at 14:10
  • 1
    Please include the error message. `"I have a syntax error"` isn't specific enough for debugging purposes. – Kimbluey Apr 02 '15 at 16:11
  • Well, those are _parts_ of the error messages. What's the context of the line of code? Please read this page: [How to create a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve) – Mooing Duck Apr 02 '15 at 16:18

3 Answers3

0

You say: I searched the web but I didn't find anything...

Google "std::vector" The first hit is

http://en.cppreference.com/w/cpp/container/vector which says:

Defined in header <vector>

So the answer is: Learn to use Google.

Dale Wilson
  • 9,166
  • 3
  • 34
  • 52
  • Well thank you for your answer but I tried that^^ The problem is Tizen doesn't recognize this header when I try to include it. #include doesn't work^^ That's the essence of the problem. – Yaoming Apr 02 '15 at 16:00
  • 1
    @Yaoming: What does "it doesn't work" mean? Does the computer catch fire? – Mooing Duck Apr 02 '15 at 16:14
  • "fatal error: file vector not found". Sorry I'm not specific enough^^ – Yaoming Apr 02 '15 at 16:17
0

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

The Tizen C++ application supports C++ based on the Standard C++ ANSI ISO 14882 2003, which includes the Standard Template Library (STL). This helps developers migrate the pre-existing standard library based applications to the Tizen platform with minimum effort.

More specifically, Tizen supports complete set of libstdc++v3 comprising of standard C++ functions specified in the Standard C++ ANSI ISO 14882 2003 and the entire Standard Template Library (http://www.sgi.com/tech/stl/).

These methods can be used by including the relevant header file in a standard manner, for example, "#include <stdio>". Support for standard C++ library extended to complete set of libstdc++v3 modules, namespaces and classes. For more information, refer to this Web site.

Remarks: The locale based feature is not supported in Tizen.

So #include <vector> should work fine.

Since you say that you can't include any C++ headers, I suspect the problem is that the compiler is compiling your code as C instead of C++. Affirm that your file has the .cpp extension, and view the file's properties in the project to confirm that the IDE is treating the file as C++. (I don't know where that setting is, I don't have Eclipse). This link says to delete your project and create a C++ project instead of a C project, then re-import your files. This link says you can set the "File Type", but also implies it doesn't quite work.

Community
  • 1
  • 1
Mooing Duck
  • 64,318
  • 19
  • 100
  • 158
  • Well `#include #include ` but those are C libraries right ? – Yaoming Apr 02 '15 at 16:30
  • @Yaoming: Correct. Did you try `#include ` and `#include `, the C++ versions? – Mooing Duck Apr 02 '15 at 16:30
  • "Fatal error: file not found" again... Maybe I need to download something? Tell Eclipse where to look to find those files ? – Yaoming Apr 02 '15 at 16:33
  • What is the full filename of the file you're compiling? Also, does the IDE have a view where you can view the files in the project, right-click this file, and view it's properties? I have a suspicion the compiler thinks you have a C file rather than C++. – Mooing Duck Apr 02 '15 at 16:35
  • Indeed the name of my file is :"cecinestpasuntest.c" (yes I'm French^^). So yes, .c and not .cpp I didn't pay attention to that... – Yaoming Apr 02 '15 at 16:37
  • Well no it doesn't work but I've added a C++ file to my project and now I should be able to work on my project^^ Thanks a lot for your answers :) – Yaoming Apr 02 '15 at 16:45
  • Good info - but not directly addressing the question. The key is the how tizen studio determines if a file is C or C++. See answer below. – TSG Oct 30 '19 at 23:42
0

I think the wrong answer was accepted...the clue is in the tags used by the OP.

The compiler used by Tizen studio determines whether a source file or header file is C or C++ based on the file extension. So if your header file is .h and you include < vector > then the compiler will complain since there is no C equivalent library for vector.

If you rename you header to .hpp, or your source to .cpp, and recompile then it will compile without error.

TSG
  • 4,242
  • 9
  • 61
  • 121