Click here to Skip to main content
15,883,705 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Difference between Typedef and #define? Pin
Rage9-Feb-06 21:20
professionalRage9-Feb-06 21:20 
GeneralRe: Difference between Typedef and #define? Pin
BadKarma9-Feb-06 22:07
BadKarma9-Feb-06 22:07 
GeneralRe: Difference between Typedef and #define? Pin
Rage10-Feb-06 1:25
professionalRage10-Feb-06 1:25 
GeneralRe: Difference between Typedef and #define? Pin
BadKarma10-Feb-06 2:15
BadKarma10-Feb-06 2:15 
GeneralRe: Difference between Typedef and #define? Pin
Rage10-Feb-06 2:55
professionalRage10-Feb-06 2:55 
GeneralRe: Difference between Typedef and #define? Pin
Ryan Binns10-Feb-06 11:58
Ryan Binns10-Feb-06 11:58 
GeneralRe: Difference between Typedef and #define? Pin
normanS12-Feb-06 20:14
normanS12-Feb-06 20:14 
AnswerRe: Difference between Typedef and #define? Pin
Ryan Binns9-Feb-06 21:41
Ryan Binns9-Feb-06 21:41 
Never, ever use #define to define new types. It's just asking for trouble.

One reason the others haven't mentioned yet is multiple variable definitions on one line. Say you do this:
#define INTPTR int*
 
INPTR p1, p2;
You may think that p1 and p2 have the same type... They do not. p1 is an int* and p2 is an int. The preprocessor expands the macro definition to produce
int* p1, p2;
Remember that the * modifies the variable, not the type, so the * only makes p1 a pointer.

Typedefs don't have this problem
typedef int* INTPTR;
 
INTPTR p1, p2;
behaves exactly as expected.

Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

GeneralRe: Difference between Typedef and #define? Pin
jhwurmbach10-Feb-06 3:09
jhwurmbach10-Feb-06 3:09 
GeneralRe: Difference between Typedef and #define? Pin
Blake Miller10-Feb-06 4:13
Blake Miller10-Feb-06 4:13 
GeneralRe: Difference between Typedef and #define? Pin
jhwurmbach10-Feb-06 4:23
jhwurmbach10-Feb-06 4:23 
GeneralRe: Difference between Typedef and #define? Pin
Blake Miller10-Feb-06 4:28
Blake Miller10-Feb-06 4:28 
GeneralRe: Difference between Typedef and #define? Pin
jhwurmbach10-Feb-06 4:34
jhwurmbach10-Feb-06 4:34 
GeneralRe: Difference between Typedef and #define? Pin
Blake Miller10-Feb-06 4:41
Blake Miller10-Feb-06 4:41 
GeneralRe: Difference between Typedef and #define? Pin
BadKarma10-Feb-06 4:38
BadKarma10-Feb-06 4:38 
GeneralRe: Difference between Typedef and #define? Pin
Blake Miller10-Feb-06 4:46
Blake Miller10-Feb-06 4:46 
GeneralRe: Difference between Typedef and #define? Pin
Ryan Binns10-Feb-06 11:53
Ryan Binns10-Feb-06 11:53 
QuestionMy string class Pin
Sarvan AL9-Feb-06 17:56
Sarvan AL9-Feb-06 17:56 
AnswerRe: My string class Pin
Bernhard9-Feb-06 19:57
Bernhard9-Feb-06 19:57 
AnswerRe: My string class Pin
Owner drawn9-Feb-06 21:22
Owner drawn9-Feb-06 21:22 
AnswerRe: My string class Pin
ThatsAlok10-Feb-06 0:06
ThatsAlok10-Feb-06 0:06 
QuestionWidescreen aspect ratio in openGL Pin
lastgen9-Feb-06 17:51
lastgen9-Feb-06 17:51 
AnswerRe: Widescreen aspect ratio in openGL Pin
lastgen12-Feb-06 2:01
lastgen12-Feb-06 2:01 
Questiondelete operator + Exception handling Pin
Sarvan AL9-Feb-06 17:45
Sarvan AL9-Feb-06 17:45 
AnswerRe: delete operator + Exception handling Pin
Owner drawn9-Feb-06 18:14
Owner drawn9-Feb-06 18:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.