freelanceprogrammers.org Forum Index » C

plz clarify...


View user's profile Post To page top
iqb_h_a Posted: Mon Jan 31, 2005 10:49 am


Joined: 24 Jan 2005

Posts: 2
plz clarify...
hi all...
      Can anybody clarify the defference between following two?

      #define NODE struct node
      typedef struct node NODE;
       
  First one is compiled by preprocessor, second one is compiled by compiler. Other than these is there any difference? Plz explain in detail...

thanks in advance

cheers
iqbal h a
Reply with quote
Send private message
View user's profile Post To page top
lenson18 Posted: Thu Feb 03, 2005 9:13 pm


Joined: 03 Feb 2005

Posts: 1
plz clarify...
"h a iqbal" <iqbal_h_a@...>
2005-01-31 10:19 AM

       
        To:
       Programmers-Town@yahoogroups.com
        cc:
       
        Subject:
       (PT) plz clarify...
        Classification:
       


>>hi all...
>>      Can anybody clarify the defference between
following two?
>>
>>      #define NODE struct node
>>      typedef struct node NODE;
>>        
>>  First one is compiled by preprocessor,
second one is compiled by compiler.
>> Other than these is there any difference? Plz
explain in detail...
>>
>> thanks in advance
>>
>>cheers
>>iqbal h a

A macro definition is "text substituted" into
the code before compilation. This will make a difference in a scenario
like:
NODE* a, b;

If the #define is used, a will be of type "pointer
to struct node", while b will be of type "struct node".
Whereas, if the typedef is used, both a and b would be
of type "pointer to struct node".

Cheers,
Lenson
Reply with quote
Send private message
View user's profile Post To page top
haque_nasir Posted: Fri Feb 04, 2005 9:38 am


Joined: 04 Feb 2005

Posts: 1
plz clarify...
#define is a macro. Typedef gives a new name to the
existing dayatype. You cant use datatype names in
#define.

--- h a iqbal <iqbal_h_a@...> wrote:
> hi all...
> Can anybody clarify the defference between
> following two?
>
> #define NODE struct node
> typedef struct node NODE;
>
> First one is compiled by preprocessor, second one
> is compiled by compiler. Other than these is there
> any difference? Plz explain in detail...
>
> thanks in advance
>
> cheers
> iqbal h a
>





___________________________________________________________
ALL-NEW Yahoo! Messenger - all new features - even more fun!
http://uk.messenger.yahoo.com
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help