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, 1725👍, 0💬
Popular Posts:
Where Is the Submitted Form Data Stored? - PHP Script Tips - Processing Web Forms When a user submit...
How To Assign Query Results to Variables? - Oracle DBA FAQ - Working with Database Objects in PL/SQL...
The object that contains all the properties and methods for every ASP.NET page, that is built is .. ...
What are database triggers? How are the triggers fired? Read this collection of questions and answer...
Advantages of a macro over a function? Macro gets to see the Compilation environment, so it can expa...