<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Feature Request: More _Generic Generics"
   href="https://bugs.llvm.org/show_bug.cgi?id=37148">37148</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Feature Request: More _Generic Generics
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>Bumblebritches57@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I'm not sure how or where to file this feature request, I was talking to Jens
Gustedt, who sits on the C standardization board, about a feature idea I had,
and he said that I basically have to find an implementation to create my
feature first before it can become the standard, which makes enough sense.

So if this is the wrong place to put this, I'd love to hear where the right
place would be.

Anyway, here's my idea for C:

What are the advantages over C++'s templates?

This method would allow a function to be created with a reasonable amount of
"genericity", without allowing everything including the kitchen sink like has
to be accepted now, and like C11's _Generic, it would not bloat the compile
time, they'd be already existing functions and the linker would just choose
which one to use at link time.


`_Typeof((((uint8_t,uint16_t), ArrayType), uint8_t:InitArray8,
uint16_t:InitArray16) uint64_t NumPlanes, uint64_t PlaneSize)(NumPlanes,
PlaneSize);`

`_Typeof((((uint8_t*,uint16_t*), Format), uint8_t*:FormatString8,
uint16_t*:FormatString16), _Typeof((*), ...))(Format, __VA_ARGS__);`

`FormatString8((_Typeof((uint8_t*,uint16_t*), Format), ...) {`
`    Types CurrentType = _Typeof(...[1]);`
`    if (CurrentType == uint8_t || CurrentType == uint16_t || CurrentType ==
uint32_t || CurrentType == uint64_t) { ConvertInteger2String(...[1]); }`
`}`

So the format would be:

Return type:         Supports a comma separated list of integral types.
Function parameters: Supports a comma separated list of integral types, or an
asterisk for any integral type


For the variadic variation, I think simply allowing the user of the
_Typeof(...[X]) could do the trick.

As for the complexity of parsing, and the backend and whatnot, I don't have a
clue, I'm not a compiler writer, I'm just some dude with an idea for how to
make C better.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>