Question
I'm trying to build the animation example project from Tizen's developer resources (originally at https://developer.tizen.org/community/tip-tech/animations-tizen-native-application) but encountering the following errors:
-
Error: implicit declaration of function 'LOGE' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
- Occurs in the main function where LOGE is used to log errors
-
Build error: ninja: build stopped: subcommand failed.
Here's the relevant code snippet causing the first error:
int main(int argc, char *argv[])
{
// ... other code ...
int ret = app_efl_main(&argc, &argv, &event_callback, &ad);
if (ret != APP_ERROR_NONE) {
LOGE("app_efl_main() is failed. err = %d", ret);
}
return ret;
}
Answer
Problem Understanding
The error occurs because the LOGE macro/function is not properly defined before its usage. This is a common issue when working with Tizen native applications that need logging functionality.
Solution Methods
-
Define the LOGE macro: Add the following definition at the top of your source file to properly define the LOGE macro using Tizen's dlog API:
#define LOGE(msg, ret) dlog_print(DLOG_ERROR, "APP_TAG", msg, ret) -
Include necessary headers: Ensure you have the required header for dlog:
#include <dlog.h> -
Clean and rebuild: After making these changes, clean your project and rebuild it.
Code Examples
Here's the complete corrected implementation:
#include <dlog.h>
#define LOGE(msg, ret) dlog_print(DLOG_ERROR, "APP_TAG", msg, ret)
int main(int argc, char *argv[])
{
appdata_s ad = {0,};
app_event_callback_s event_callback;
event_callback.create = app_create;
event_callback.terminate = app_terminate;
event_callback.pause = app_pause;
event_callback.resume = app_resume;
event_callback.app_control = NULL;
event_callback.low_memory = NULL;
event_callback.low_battery = NULL;
event_callback.device_orientation = NULL;
event_callback.region_format_changed = NULL;
int ret = app_efl_main(&argc, &argv, &event_callback, &ad);
if (ret != APP_ERROR_NONE) {
LOGE("app_efl_main() failed. err = %d", ret);
}
return ret;
}
Additional Tips
- You can view the logs in Tizen Studio's Log View. Set the log level to VERBOSE (V) to see your error messages.
- Consider using different log levels (DLOG_ERROR, DLOG_WARN, DLOG_INFO) appropriately for different types of messages.
- Make sure to define a meaningful tag (instead of "APP_TAG") that identifies your application in the logs.