advertisement
Premier Club Log In/Registration
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   SKILLBUILDING  |   TIP BANK  |   SOURCEBANK  |   FORUMS  |   NEWSLETTERS
Browse DevX
Typedefs, as we have seen, can simplify coding and improve readability. Yet programmers often misuse them by declaring unnecessary typedefs that only obfuscate code. A good example of such misuse is C-style struct declarations in the form: typedef struct {} S; Many programming languages don't even have a similar mechanism. What are your rules of thumb regarding typedef usage? Tell us in our c.general discussion group.
Partners & Affiliates
advertisement
advertisement
advertisement
Average Rating: 4.1/5 | Rate this item | 9 users have rated this item.
 

Using typedef to Curb Miscreant Code

Typedef declarations help create platform-independent types and can even hide complex or unintelligible syntax. Predictably, however, using typedef comes with its own set of surprises. Learn how to navigate these pitfalls and use typedef to clean up your code.  


advertisement
typedef declaration, or a typedef for short, creates a new name for an existing type. As such, it is often used in writing more aesthetic and readable code. Aesthetics not withstanding, typedefs can also hide unwieldy syntactic constructs and platform-dependent datatypes, thereby enhancing portability and future maintenance. The following sections show how to exert the power of typedef while avoiding common traps.


How to create platform-independent datatypes and hide cumbersome, if not unintelligible, syntax?


Use typedefs to create synonyms for existing types.

  Next Page: Defining Mnemonic Type Names
Page 1: IntroductionPage 3: Code Simplification
Page 2: Defining Mnemonic Type Names 
Please rate this item (5=best)
 1  2  3  4  5
advertisement
Advertising Info  |   Member Services  |   Permissions  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs