This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Calculate the size of all variables


Dear helpers,
I want to calculate the size of all variables in a function. I try with the following code but it doesn't run. Please help me. Thank you very much.

int size_of_vars (fndecl) //fndecl is FUNCTION_DECL
     tree fndecl;
{
  tree t;
  HOST_WIDE_INT total_size = 0;
  tree let = DECL_INITIAL (fndecl);
  for (t = BLOCK_VARS (let); t; t = TREE_CHAIN (t))
    total_size += int_size_in_bytes (TREE_TYPE (t));

  /* Process all subblocks.  */
  for (t = BLOCK_SUBBLOCKS (let); t; t = TREE_CHAIN (t))
    total_size += size_of_vars (t);
  }
  return total_size;
}

Regard,
Le Ton Chanh
email: letonchanh at yahoo dot com
Le Ton Chanh 
email: letonchanh at yahoo dot com


      


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]