0

I have following code snippet from the dalvikvm source code. While building I am getting following error,

error: expected '=', ',', ';', 'asm' or '__attribute__' before '+=' token

in the code snippet,

    #ifdef CHECK_BRANCH_OFFSETS                                                     
# define ADJUST_PC(_offset) do {                                                \
        int myoff = _offset;        /* deref only once */                       \
        if (pc + myoff < curMethod->insns ||                                    \
            pc + myoff >= curMethod->insns + dvmGetMethodInsnsSize(curMethod))  \
        {                                                                       \
            char* desc;                                                         \
            desc = dexProtoCopyMethodDescriptor(&curMethod->prototype);         \
            LOGE("Invalid branch %d at 0x%04x in %s.%s %s\n",                   \
                myoff, (int) (pc - curMethod->insns),                           \
                curMethod->clazz->descriptor, curMethod->name, desc);           \
            free(desc);                                                         \
            dvmAbort();                                                         \
        }                                                                       \
        pc += myoff;                                                            \
        EXPORT_EXTRA_PC();                                                      \
    } while (false)
#else
# define ADJUST_PC(_offset) do {                                                \                                   
        pc += _offset;                                                          \
        EXPORT_EXTRA_PC();                                                      \
    } while (false)
#endif

The error is showing for pc +=_offset; line.

P basak
  • 4,874
  • 11
  • 40
  • 63
  • 1
    Hard to say without knowing what pc and _offset are when ADJUST_PC() is instantiated. – Charlie Burns Oct 15 '13 at 00:29
  • That's just a macro definition. Check the context where it's actually failing and figure out how `pc` is defined at that point. If you're compiling `dalvik/vm/mterp/out/InterpC-portable.cpp`, it's declared at the top of `dvmInterpretPortable`. One trick: use "make showcommands" to get the full command line, then execute it manually, adding `-save-temps`. That'll get you a `.i` file, which has the preprocessor symbols expanded. – fadden Oct 15 '13 at 00:40
  • 1
    If that's an exact copy of your code, then it's probably because you've got whitespace after the backslash on the previous line. The backslash has to be the very last character on the line to continue the macro definition into the next line. – Mike Seymour Oct 15 '13 at 00:43
  • @fadden very helpful information. Thanks. – P basak Oct 15 '13 at 00:47
  • @fadden can you have a look on my latest question, http://stackoverflow.com/questions/19416608/compilin-error-fields-must-have-a-constant-size-variable-length-array-in-stru – P basak Oct 17 '13 at 01:16

0 Answers0