By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,332 Members | 1,404 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,332 IT Pros & Developers. It's quick & easy.

C macros tuts needed

P: n/a
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
Nov 14 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
sathyashrayan wrote:

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.

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
Nov 14 '05 #2

P: n/a
CBFalconer <cb********@yahoo.com> wrote in message news:<40***************@yahoo.com>...
sathyashrayan wrote:

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.


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
Nov 14 '05 #3

P: n/a
sathyashrayan <sa************@yahoo.co.in> wrote:
CBFalconer <cb********@yahoo.com> wrote in message news:<40***************@yahoo.com>...
sathyashrayan wrote:
>
> 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.


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.

--
Z (Zo**********@daimlerchrysler.com)
"LISP is worth learning for the profound enlightenment experience
you will have when you finally get it; that experience will make you
a better programmer for the rest of your days." -- Eric S. Raymond
Nov 14 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.