title: Can I get "macro polymorphism" in C
body: <p>The type of polymorphism I'm after is this:</p>
  
  <p>suppose I have a macro called draw(), and I have 2 structs, one called circle and the other called square. Is is possible to somehow do something like this:</p>
  
  <pre><code>#define draw() // can I get the text that's behind the macro?
  //then maybe, with _Generic achieve this?
  
  
  void draw_circle(struct circle);
  void draw_square(struct square);
  
  struct circle c;
  struct square s;
  
  c.draw();//draw is a macro. this time it is supposed to expand to draw_circle(c);
  s.draw();//supposed to expand to draw_square(s);
  </code></pre>
  
  <p><strong>EDIT_1:</strong> this is what I have so far, after reading your answers.</p>
  
  <pre><code>//raw_array.h
  #pragma once
  #include &lt;stdint.h&gt;
  #include &lt;stdlib.h&gt;
  
  #define byte uint8_t
  #define _GET_OVERRIDE(_1, _2, _3, NAME, ...) NAME
  /*#define init_impl(...) _GET_OVERRIDE(__VA_ARGS__, \
      init_impl3, init_impl2, init_impl1)(__VA_ARGS__)
  #define init( name, ... ) (raw_array * (name); init_impl( (name), __VA_ARGS__))*/
  
  #define array_init_impl(...) _GET_OVERRIDE(__VA_ARGS__, init_array_impl3, init_array_impl2, init_array_impl1)(__VA_ARGS__)
  
  ///&lt;summary&gt;creates a variable of type raw_array with name as an identifier, and initializes based on the parameters&lt;/summary&gt;
  #define RAW_ARRAY( name, ... ) raw_array (name); array_init_impl( (&amp;name), __VA_ARGS__)
  typedef struct indexable_memory_block_struct
  {
      raw_array * _self;
      byte * bytes;
      size_t element_size;
      size_t number_of_elements;
  
  } raw_array;
  
  ///&lt;summary&gt;starts the an empty raw_array. only element_size is set.&lt;/summary&gt;
  ///&lt;param name=r_arr&gt;the raw_array to be initialized&lt;/param&gt;
  ///&lt;param name=element_size&gt;the size of the elements in this raw_array&lt;/param&gt;
  void init_impl1 ( raw_array * r_arr, size_t element_size )
  {
      r_arr = malloc ( sizeof ( raw_array ) );
      r_arr-&gt;element_size = element_size;
      r_arr-&gt;number_of_elements = 0;
      r_arr-&gt;bytes = NULL;
      r_arr-&gt;_self = r_arr;
  }
  
  ///&lt;summary&gt;
  ///starts the raw_array an empty. byte with its bytes allocated
  ///to their default value (0).
  ///&lt;/summary&gt;
  ///&lt;param name=r_arr&gt;the raw_array to be initialized&lt;/param&gt;
  ///&lt;param name=element_size&gt;the size of the elements in this raw_array&lt;/param&gt;
  ///&lt;param name=number_of_elements&gt;the number of elements in the array&lt;/param&gt;
  void init_impl2 ( raw_array * r_arr, size_t element_size, size_t number_of_elements )
  {
      r_arr = malloc ( sizeof ( raw_array ) );
      r_arr-&gt;element_size = element_size;
      r_arr-&gt;number_of_elements = number_of_elements;
      r_arr-&gt;bytes = calloc ( number_of_elements, element_size );
      r_arr-&gt;_self = r_arr;
  }
  
  ///&lt;summary&gt;
  ///starts the raw_array copying its contents from a normal array.
  ///&lt;/summary&gt;
  ///&lt;param name=r_arr&gt;the raw_array to be initialized&lt;/param&gt;
  ///&lt;param name=arr&gt;the normal C array whose contents will be copied to this raw_array&lt;/param&gt;
  ///&lt;param name=element_size&gt;the size of the elements in this    raw_array&lt;/param&gt;
  ///&lt;param name=number_of_elements&gt;the number of elements in the array&lt;/param&gt;
  void init_impl3 ( raw_array * r_arr, const void * const arr, size_t size_of_element, size_t number_of_elements )
  {
      r_arr-&gt;bytes = malloc ( size_of_element * number_of_elements );
  
      memcpy ( r_arr-&gt;bytes, arr, size_of_element * number_of_elements );
      r_arr-&gt;element_size = size_of_element;
      r_arr-&gt;number_of_elements = number_of_elements;
      r_arr-&gt;_self = r_arr;
  }
  </code></pre>
  
  <p>there are other parts, but these are the ones currently being ported to this new syntax. Now main:</p>
  
  <pre><code>int main ( int argc, char * argv[] )
  {
      int data[30];
  
      //line bellow has a compilation error: *expected a ')'*
      init ( r_arr, data, sizeof ( int ), 30 );
  }
  </code></pre>
  
  <p>what does it mean expected a ')'
  could you guys check out the macro syntax?
  About _Generic, I learned about it today, and I'll use it if it's useful, for sure.</p>
  
  <p><strong>EDIT_2:</strong> found a gross error, will be fixing it and editing again. Visual Studio is updating (12GB...) So I can't build anything at the moment. [mini-edit]: Guess I fixed the gross error at least. [mini-edit] another very bizarre error in my code, I stringifyed the name token, wth?! corrected now.</p>
  
  <p><strong>EDIT_3:</strong> having slept and having VS operational again, I fixed the macros, will edit them and comment out the wrong code. Now I need to the <code>circle.draw()</code> behaviour... any ideas?</p>