Question
I'm developing a Tizen native application using Tizen Studio with main.c and main.h files. Currently, I'm only using unsigned char for text handling, but I'd like to utilize both C++ string and Tizen::Base::String.
I have several specific questions:
- How can I use both C++ string and Tizen::Base::String in my project?
- When I try to change main.c to main.cpp, I encounter errors. Is there a proper way to convert from C to C++?
- Does Tizen::Base::String support C, or is it only for C++?
- Is Tizen::Base::String a class like Android and C++ strings? Where can I find documentation about Tizen variable types?
Answer
Problem Understanding
The user wants to use C++ string functionality in a Tizen native application that's currently written in C. They're encountering difficulties when trying to switch from C to C++ and need clarification about string handling options in Tizen.
Solution Methods
-
Using C++ in Tizen Native Applications:
- Tizen primarily uses C for native applications, but C++ can be used with proper configuration
- To use C++:
a. Rename your source files to use .cpp extension
b. Configure the project settings:
- Right-click project → Properties → C/C++ Build → Settings → Tool Settings → C++ Compiler → Dialect
- Select C++11 from "Language Standard"
- Go to Properties → C/C++ Build → Tizen Settings → Platform
- In "Toolchain Information", select either GCC-4.9 or LLVM GCC-4.9 from "Name" dropdown
-
String Handling Options:
- For C development: Use standard C string functions (strcpy, strlen, etc.) with char arrays
- For C++ development: You can use std::string or Tizen::Base::String
- Tizen::Base::String is a C++ class and not available for pure C development
-
Documentation Resources:
- For Tizen::Base::String and other C++ classes, refer to the official documentation at samsungtizenos.com
- The documentation primarily shows methods, but you can find class definitions there as well
Additional Tips
- When using C strings, remember to properly manage memory allocation and deallocation
- For Unicode support, consider using Tizen's i18n libraries
- If you're new to Tizen development, examine the sample applications in Tizen Studio under Mobile UI segment for reference implementations