[edk2] [EDK2] gcc typeof equivalent?

Subject: [edk2] [EDK2] gcc typeof equivalent?

From: Ian Noone <iannoone@hotmail.com>

To: EDK2-DEVELOPER_FORUM <edk2-devel@lists.sourceforge.net>

Date: 2012-06-09 06:49:58

Hi,

I inherited a Linux driver and have been porting part of it to my EBC driver.

I recently ran into 2 problems:
1.  gcc typeof
     I don't know how to work around this problem so I just substitute typeof(*pos) with UINT64.  This seems to get passed the problem.

2.  In a subroutine called my_add_bvec ( struct einstein_dev *dev, struct bvec_list_node *bvec_node) [see code snippet at the end of the message], I've problem with this line of code:
     list_for_each_entry_reverse(bn, &dev->bvec_list.lh, lh)
  
     The compiler error message (for list_for_each_entry_reverse) is: expression must have pointer-to-struct-or-union type
     This line of code compiles just fine using gcc but not when I use Visual Studio 2008 or Intel EBC.

My questions are:
1.  Is there any equivalent for gcc typeof for VS2008 / Intel EBC ?  I know that, for my particular case, the size should be 8 bytes so I returned (hard coded) the value UINT64. 

2.  Why the warning on EBC compiler / VS 2008 compiler but not gcc?

Thanks much for any help!


-----------------


my_add_bvec (struct einstein_dev *dev, struct bvec_list_node *bvec_node) {
     struct bvec_list_node *bn = NULL;

     if (dev->bvec_pending_node == &dev->bvec_list) {
          list_add_tail(&bvec_node->lh, &dev->bvec_list.hl);
     }
     else if (bvec_node_dir == READ) {
          list_for_each_entry_reverse(bn, &dev->bvec_list.lh, lh); <---------------------------------- compiler problem here
     }
}

#define list_for_each_entry_reverse(pos, head, member)                  \
        for (pos = list_entry((head)->prev, UINT64, member);      \
             &pos->member != (head);    \
             pos = list_entry(pos->member.prev, UINT64, member))

#define list_entry(ptr, type, member) \
((type *)((char *)(ptr) - (unsigned long)(&((type *)0)->member)))

struct einstein_dev {
    ...  
    struct bvec_list_node  bvec_list;
 
};  // end of einstein_dev

struct bvec_list_node {
   ...
    struct list_head       lh;
};  // end of bvec_list struct

struct list_head {
    struct list_head *next, *prev;
}