Search code examples
c++cbinutils

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


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 ?


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.