Re: How do I do generic programming in C?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • user923005

    Re: How do I do generic programming in C?

    On May 13, 10:21 am, "Robbie Hatley"
    <see.my.signat. ..@for.my.email .addresswrote:
    [snip]
    So... is there any way of emulating templates in C?
    Or do I just have to live with duplicate functions?
    Not really, but you can do like I did in chapter 13 of "C Unleashed":

    Windows line endings:


    Unix line endings:


    You will see that I generate the appropriate source code by defining a
    macro. It's "somewhat template like" in a perverse sort of way. In
    fact, the code turns into templates if you use C++ to compile it.
  • user923005

    #2
    Re: How do I do generic programming in C?

    On May 14, 3:52 pm, user923005 <dcor...@connx. comwrote:
    On May 13, 10:21 am, "Robbie Hatley"<see.my. signat...@for.m y.email.address wrote:
    >
    [snip]
    >
    So... is there any way of emulating templates in C?
    Or do I just have to live with duplicate functions?
    >
    Not really, but you can do like I did in chapter 13 of "C Unleashed":
    >
    Windows line endings:http://www.cpax.org.uk/prg/portable/...cubookcode.zip
    >
    Unix line endings:http://www.cpax.org.uk/prg/portable/...ookcode.tar.gz
    >
    You will see that I generate the appropriate source code by defining a
    macro.  It's "somewhat template like" in a perverse sort of way.  In
    fact, the code turns into templates if you use C++ to compile it.
    You can also get the chapter 13 only stuff here:

    Comment

    Working...