Maybe what ikegami meant was that the underscore is not needed. Struct names live in a different namespace, so you can write
typedef struct host host;

Of course, I recommend much longer struct names since C namespace is so limiting. I usually name my stuff with a project identifier prefix, like struct myproj_host. I find CamelCase and lowercase equally appealing for the prefix and object names, but tend to stick to one pattern per project. I often put a suffix of _t on my typedefs, and _p on pointer typedefs, but that would also make the CTL library generate ugly code. Whoops I just looked it up, and "_t" are reserved. So I guess I won't do that anymore. Sometimes I don't declare any typedefs and just live with 'struct' declared everywhere. It isn't pretty, but C is never really pretty and it helps document the code for people less familiar with it. I suppose the typedefs are required for that library you're using though, and with it putting prefixes on your type names for the container name that is only going to look OK with lowercase...

Maybe if the CTL library were written in cpppp it would be easier to parameterize the output :-)

(that vector class isn't finished; but maybe CTL would make a good model to base my eventual set of standard templates on)


In reply to Re^5: OT: Why does malloc always give me 24? by NERDVANA
in thread OT: Why does malloc always give me 24? [SOLVED] by karlgoethebier

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.