4

I trying to use va_start and va_end functions in my project, but eclipse don't want to resolve it as functions. gcc compiles whole project without errors...

[myfile.cpp]

#include <stdio.h>
#include <stdarg.h>
[...]
inline void ShowDbgMsg( const char* str, ... )
{
    va_list argptr;
    va_start(argptr, str);
    vprintf(str, argptr);
    va_end(argptr);
}
[...]

[Android.mk]

[...]
LOCAL_C_INCLUDES := jni/pvrTools/ jni/igel/ $(STLPORT_BASE)/stlport
[...]

Eclipse says:

[...]
Description Resource    Path    Location    Type
Function 'va_start' could not be resolved   igel.comdef.h   /NativeProject/jni/igel    line 195 Semantic Error
Function 'va_end' could not be resolved igel.comdef.h   /NativeProject/jni/igel  line 203   Semantic Error
Function 'va_start' could not be resolved   igel.string.h   /NativeProject/jni/igel line 341    Semantic Error
Function 'va_end' could not be resolved igel.string.h   /NativeProject/jni/igel line 351    Semantic Error
[...]

So, it looks like Eclipse unable to locate something... How to solve this issue? Thanks in advance!

P.S.> Project->Index->Rebuild didn't help. :(

3 Answers 3

8

My solution is also not pretty. But after you've deleted the error markers 100 times, try putting this code somewhere before you include stdlib.h. Then define ECLIPSEBUILD=1 in Project::Properties::C++ General::Paths and Symbols.

  

    #if ECLIPSEBUILD // this part is just to fix spurious Eclipse errors
    typedef __builtin_va_list va_list;
    #define va_start(v,l)   __builtin_va_start(v,l)
    #define va_end(v)   __builtin_va_end(v)
    #define va_arg(v,l) __builtin_va_arg(v,l)
    #if !defined(__STRICT_ANSI__) || __STDC_VERSION__ + 0 >= 199900L || defined(__GXX_EXPERIMENTAL_CXX0X__)
    #define va_copy(d,s)    __builtin_va_copy(d,s)
    #endif
    #define __va_copy(d,s)  __builtin_va_copy(d,s)
    typedef __builtin_va_list __gnuc_va_list;
    typedef __gnuc_va_list va_list;
    typedef va_list __va_list;
    #endif

 
0

I solve this issue by replacing my va_* code with embedded compiler features:

#ifdef IGEL_PLATFORM_ANDROID
#   define ShowDbgMsg(...)  ((void)__android_log_print(ANDROID_LOG_INFO, "igel-debug", __VA_ARGS__))
#else
inline void ShowDbgMsg( const char* str, ... )
{
    va_list argptr;
    va_start(argptr, str);
    vprintf(str, argptr);
    va_end(argptr);
}
#endif // IGEL_PLATFORM_ANDROID

I know it's not a good solution, but it works.

0
#include <stdarg.h> // includes va_list

inline void ShowDbgMsg(char* format, ...)
{
  va_list ap;      
  va_start( ap, format );

// replace vfprintf( stderr, format, ap ) with:

   __android_log_vprint(0, __FILE__, format, ap);
  va_end( ap );
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.