473,508 Members | 2,202 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C macros tuts needed

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
3 1778
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
2959
by: Chris Reedy | last post by:
For everyone - Apologies for the length of this message. If you don't want to look at the long example, you can skip to the end of the message. And for the Python gurus among you, if you can...
37
2750
by: michele.simionato | last post by:
Paul Rubin wrote: > How about macros? Some pretty horrible things have been done in C > programs with the C preprocessor. But there's a movememnt afloat to > add hygienic macros to Python. Got any...
3
5814
by: Prakash | last post by:
Hi, We face problems uploading excel (with macros) documents using HTML File Upload. The file contents are corrupted while viewing the same. However, we are able to upload excel (w/o. macros)...
25
9075
by: Sabyasachi Basu | last post by:
While trying to port some stuff from Unix to Windows, I encountered a strange behaviour of function macros with empty arguments. Here is a small snippet which illustrates the problem: #include...
1
1194
by: paddy | last post by:
I keep digging through tut after tut and I find lots and lots of C++ logic, but I can't find any straight forward plain and simple info on the whole linking and library process. Can anyone...
6
2795
by: Reg | last post by:
At present I'm running a number of macros with a schedular on my computer to update and maintain databases within our network. All my backends contain the tables that the macros update. But all the...
3
2652
by: Stephen Sprunk | last post by:
On a project I'm working on, I ran across the following macros: /* assume s is struct stream *, s->p is char, v is unit16_t or uint32_t */ #define in_uint16_le(s,v) { v = *((s)->p++); v +=...
3
3984
by: dan_roman | last post by:
Hi, I developed a script with a nice interface in Tkinter that allows me to edit some formulas and to generate an Excel worksheet with VBA macros within it. The script runs perfectlly in Office...
20
3361
by: copx | last post by:
Is it true that C macros are unsafe when combined with side effects even if they are "clean" e.g. could foo_macro(++c); execute "++c" multiple times even if foo_macro is "clean"? I have always...
0
7127
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7391
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7054
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7501
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4713
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3204
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1564
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
768
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.