Question

I am trying to build an old binutils (2.13). getting the error ./config/obj-elf.c:364: error: invalid type argument of ‘->’ (have ‘int’) on the next line :

if (symbol_get_obj (symbolP)->local)
{...

the function symbol_get_obj :

OBJ_SYMFIELD_TYPE *
symbol_get_obj (s)
     symbolS *s;
{
  if (LOCAL_SYMBOL_CHECK (s))
    s = local_symbol_convert ((struct local_symbol *) s);
  return &s->sy_obj;
}

OBJ_SYMFIELD_TYPE is defined to be :

#define OBJ_SYMFIELD_TYPE struct elf_obj_sy

and elf_obj_sy is

struct elf_obj_sy
{
  /* Whether the symbol has been marked as local.  */
  int local;

  /* Use this to keep track of .size expressions that involve
     differences that we can't compute yet.  */
  expressionS *size;

  /* The name specified by the .symver directive.  */
  char *versioned_name;

#ifdef ECOFF_DEBUGGING
  /* If we are generating ECOFF debugging information, we need some
     additional fields for each symbol.  */
  struct efdr *ecoff_file;
  struct localsym *ecoff_symbol;
  valueT ecoff_extern_size;
#endif
};

couldn't understand what is wrong with this code ... any advice ?

Était-ce utile?

La solution

Based on the error message, one possible reason is that the declaration of the function symbol_get_obj fails to appear before the place you call it, which makes the return value default to type int, an invalid type for operator ->. You might want to check this. Make sure the correct presence of symbol_get_obj's declaration through header file inclusion or explicit function prototype.

Autres conseils

invalid type argument of ‘->’ (have ‘int’)

That can only make sense if

symbol_get_obj(symbolP)

returns int. Which it does not.

So, the only logical conclusion is that symbol_get_obj has not been declared at the point in the code where the error occurs. In which case the compiler will assume that it is a function that returns a value of type int. Which would then explain the error message.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top