List:Internals« Previous MessageNext Message »
From:Martin Friebe Date:March 15 2007 9:29pm
Subject:static friend in item_sum.cc
View as plain text  
Hi!

just a very small thing I noted, but maybe it reaches the person, who
wrote it:
(and maybe its still of interest)

In sql/item_sum.cc  (aprox line 2325) is the following remark:
> /*
>   Did not make this one static - at least gcc gets confused when
>   I try to declare a static function as a friend. If you can figure
>   out the syntax to make a static function a friend, make this one
>   static
> */
>
> static int composite_key_cmp(void* arg, byte* key1, byte* key2)
If it is of any interest, below is a patch, that works with gcc.
The trick is, in the header file declare the function as static, before
the class declaration.
And as friend inside the class declaration.

Hope this is the right mailing list for this.

Cheers
Martin


*** sql/item_sum.h      Thu Jan 11 14:40:02 2007
--- ../mysql-5.0.bk/sql/item_sum.h      Thu Mar 15 21:06:09 2007
***************
*** 535,542 ****
--- 535,543 ----
  };


  class TMP_TABLE_PARAM;
+ static int composite_key_cmp(void* arg, byte* key1, byte* key2);

  class Item_sum_count_distinct :public Item_sum_int
  {
    TABLE *table;
*** sql/item_sum.cc     Wed Feb 21 11:05:00 2007
--- ../mysql-5.0.bk/sql/item_sum.cc     Thu Mar 15 21:02:43 2007
***************
*** 2329,2337 ****
    out the syntax to make a static function a friend, make this one
    static
  */

! int composite_key_cmp(void* arg, byte* key1, byte* key2)
  {
    Item_sum_count_distinct* item = (Item_sum_count_distinct*)arg;
    Field **field    = item->table->field;
    Field **field_end= field + item->table->s->fields;
--- 2329,2337 ----
    out the syntax to make a static function a friend, make this one
    static
  */

! static int composite_key_cmp(void* arg, byte* key1, byte* key2)
  {
    Item_sum_count_distinct* item = (Item_sum_count_distinct*)arg;
    Field **field    = item->table->field;
    Field **field_end= field + item->table->s->fields;


Thread
static friend in item_sum.ccMartin Friebe15 Mar
  • Re: static friend in item_sum.ccChad MILLER16 Mar