Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
What's the difference between using a typedef or a define for a user-defined type?
What's the difference between using a typedef or a define for a user-defined type?
✍: Guest
In general, typedefs are preferred, in part because they can correctly encode pointer types. For example, consider these declarations:
typedef char *String_t;
#define String_d char *
String_t s1, s2;
String_d s3, s4;
s1, s2, and s3 are all declared as char *, but s4 is declared as a char, which is probably not the intention.
#defines do have the advantage that #ifdef works on them On the other hand, typedefs have the advantage that they obey scope rules (that is, they can be declared local to a function or block).
2016-02-22, 1266👍, 0💬
Popular Posts:
What will be printed as the result of the operation below: main() { int x=5; printf("%d,%d,%d\n",x,x. ..
How can I execute a PHP script using command line? Just run the PHP CLI (Command Line Interface) pro...
How Many Types of Tables Supported by Oracle? - Oracle DBA FAQ - Managing Oracle Database Tables Ora...
How To Merge Cells in a Row? - XHTML 1.0 Tutorials - Understanding Tables and Table Cells If you wan...
Can static variables be declared in a header file? You can't declare a static variable without defin...