C macros tuts needed

S

sathyashrayan

Friends,
Can any body suggest any link to a tutorial, which can cover
various concepts of using macro in a program? I have seen macros used
to over come the endiness problems, portability issues, generality
etc. But I don't understand how it is been done.

Thanks
 
C

CBFalconer

sathyashrayan said:
Can any body suggest any link to a tutorial, which can cover
various concepts of using macro in a program? I have seen macros
used to over come the endiness problems, portability issues,
generality etc. But I don't understand how it is been done.

Limit yourself to #define CONST for now. Macros don't really
solve any problems, they just encapsulate them.

Any time you see a complex macro it isn't doing anything you
couldn't do yourself by writing things out in full. If you don't
understand what the code is doing, you can't write a macro to
implement it. There is no magic, just text replacement.
 
S

sathyashrayan

CBFalconer said:
Limit yourself to #define CONST for now. Macros don't really
solve any problems, they just encapsulate them.

Any time you see a complex macro it isn't doing anything you
couldn't do yourself by writing things out in full. If you don't
understand what the code is doing, you can't write a macro to
implement it. There is no magic, just text replacement.

I think I am confusing with pre-defined const and macros such as
__FILE__, __TIME__ __DATE__ , etc with that of normal macro
definitions. Ain't I ?

I have come across several macro constants apart from those defined in
6.10.8 of the standard. Does each compiler has it's own macro constant
other than the standard. I hope this is not an OT.

Thanks for the replay
 
Z

Zoran Cutura

sathyashrayan said:
I think I am confusing with pre-defined const and macros such as
__FILE__, __TIME__ __DATE__ , etc with that of normal macro
definitions. Ain't I ?

I can't tell whether you're confusing 'em, but you may try to actually
ask a question about what you don't understand, about these defines?
I have come across several macro constants apart from those defined in
6.10.8 of the standard. Does each compiler has it's own macro constant
other than the standard. I hope this is not an OT.

Implementations (i.e. compilers) may introduce other macro constants,
but they have to define those in 6.10.8. You'll need to consult the
compilers manual/documentation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,173
Latest member
GeraldReund
Top