let define_named_struct ~env ~is_union name newdef = 
  try
    match List.assoc name env.struct_name_table with
      StructName id -> 
        let desc = get_struct_desc ~env id in
        if desc.str_union_p <> is_union then
          raise (Type_Error_local "name of union/struct crash with other struct/union name");
        if desc.str_size <> None then
          raise (Type_Error_local ("duplicated definition of struct " ^ name));
        set_struct_desc ~env id newdef;
        id
    | EnumName ->
        raise (Type_Error_local "name of union/struct crash with other enum name")
  with
    Not_found ->
      let id = make_new_struct_id () in
      env.struct_table <- (id, ref newdef) :: env.struct_table;
      env.struct_name_table <- (name, StructName id) :: env.struct_name_table;
      id