Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 2. Preprocessor (PRE) > PRE03-C. Prefer type definitions to defines for...

PRE03-C. Prefer type definitions to defines for encoding types

Prefer type definitions (typedef) to macro definitions (#define) when encoding types. Type definitions obey scope rules, whereas macro definitions do not. Type definitions can also correctly encode pointer types because they are not implemented as simple textual substitution. In this type definition, for example, the variable p is declared as a constant pointer to char [Summit 05]:

typedef char *NTCS;
const NTCS p = &data;


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint