473,397 Members | 2,077 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Differences between Functio & Macro in C

Hi all,
I want to know the differebces between function and macro in c
language. if anybody can tell me atleast 4 diff's. for which i will
be regrated.

Rgds,
Balaji

Nov 15 '05 #1
13 1681
In article <d9**********@domitilla.aioe.org>,
uma676 <um*************@gmail-dot-com.no-spam.invalid> wrote:
I want to know the differebces between function and macro in c
language. if anybody can tell me atleast 4 diff's. for which i will
be regrated.


Why "at least 4"?

Without further explanation this sounds like a homework problem.
--
Rouben Rostamian
Nov 15 '05 #2
In article <d9**********@pc18.math.umbc.edu>,
Rouben Rostamian <ro****@pc18.math.umbc.edu> wrote:
In article <d9**********@domitilla.aioe.org>,
uma676 <um*************@gmail-dot-com.no-spam.invalid> wrote:
I want to know the differebces between function and macro in c
language. if anybody can tell me atleast 4 diff's. for which i will
be regrated.

I wouldn't want to be the cause of your being regrated. That sounds like
it would hurt.
Why "at least 4"?

Without further explanation this sounds like a homework problem.


Gee, ya think?

Nov 15 '05 #3
Kenny McCormack wrote:
Rouben Rostamian <ro****@pc18.math.umbc.edu> wrote:
uma676 <um*************@gmail-dot-com.no-spam.invalid> wrote:

I want to know the differebces between function and macro in c
language. if anybody can tell me atleast 4 diff's. for which i
will be regrated.


I wouldn't want to be the cause of your being regrated. That
sounds like it would hurt.


What a cheesy thing to say. :-)

--
"I'm a war president. I make decisions here in the Oval Office
in foreign policy matters with war on my mind." - GWB 2004-2-8
"If I knew then what I know today, I would still have invaded
Iraq. It was the right decision" - G.W. Bush, 2004-08-02
"This notion that the United States is getting ready to attack
Iran is simply ridiculous. And having said that, all options
are on the table." - George W. Bush, Brussels, 2005-02-22
Nov 15 '05 #4
On Mon, 27 Jun 2005 17:05:54 -0500, CBFalconer wrote
(in article <42***************@yahoo.com>):
Kenny McCormack wrote:
Rouben Rostamian <ro****@pc18.math.umbc.edu> wrote:
uma676 <um*************@gmail-dot-com.no-spam.invalid> wrote:

I want to know the differebces between function and macro in c
language. if anybody can tell me atleast 4 diff's. for which i
will be regrated.


I wouldn't want to be the cause of your being regrated. That
sounds like it would hurt.


What a cheesy thing to say. :-)


That's just full of holes.

Nov 15 '05 #5
In article <00*****************************@news.verizon.net> ,
Lefty Bigfoot <nu***@busyness.info> wrote:

On Mon, 27 Jun 2005 17:05:54 -0500, CBFalconer wrote
(in article <42***************@yahoo.com>):
Kenny McCormack wrote:
Rouben Rostamian <ro****@pc18.math.umbc.edu> wrote:
uma676 <um*************@gmail-dot-com.no-spam.invalid> wrote:

> I want to know the differebces between function and macro in c
> language. if anybody can tell me atleast 4 diff's. for which i
> will be regrated.

I wouldn't want to be the cause of your being regrated. That
sounds like it would hurt.


What a cheesy thing to say. :-)


That's just full of holes.


They can't make jokes like that in Iraq, it upsets the Kurds.
--
7842++
Nov 15 '05 #6
On 2005-06-27 21:58:16 -0400, an******@example.com (Anonymous 7843) said:
In article <00*****************************@news.verizon.net> ,
Lefty Bigfoot <nu***@busyness.info> wrote:

On Mon, 27 Jun 2005 17:05:54 -0500, CBFalconer wrote
(in article <42***************@yahoo.com>):
Kenny McCormack wrote:
Rouben Rostamian <ro****@pc18.math.umbc.edu> wrote:
> uma676 <um*************@gmail-dot-com.no-spam.invalid> wrote:

>> I want to know the differebces between function and macro in c
>> language. if anybody can tell me atleast 4 diff's. for which i
>> will be regrated.

I wouldn't want to be the cause of your being regrated. That
sounds like it would hurt.

What a cheesy thing to say. :-)


That's just full of holes.


They can't make jokes like that in Iraq, it upsets the Kurds.


Wow, this thread has gone whey off topic.

--
Clark S. Cox, III
cl*******@gmail.com

Nov 15 '05 #7
On Mon, 27 Jun 2005 22:27:27 -0400, Clark S. Cox III wrote:
On 2005-06-27 21:58:16 -0400, an******@example.com (Anonymous 7843) said:
In article <00*****************************@news.verizon.net> , Lefty
Bigfoot <nu***@busyness.info> wrote:

On Mon, 27 Jun 2005 17:05:54 -0500, CBFalconer wrote (in article
<42***************@yahoo.com>):

Kenny McCormack wrote:
> Rouben Rostamian <ro****@pc18.math.umbc.edu> wrote:
>> uma676 <um*************@gmail-dot-com.no-spam.invalid> wrote:
>
>>> I want to know the differebces between function and macro in c
>>> language. if anybody can tell me atleast 4 diff's. for which i will
>>> be regrated.
>
> I wouldn't want to be the cause of your being regrated. That sounds
> like it would hurt.

What a cheesy thing to say. :-)

That's just full of holes.


They can't make jokes like that in Iraq, it upsets the Kurds.


Wow, this thread has gone whey off topic.


Come on everyone, stop milking the jokes.

Nov 15 '05 #8


Netocrat wrote:
[snipped...]

Come on everyone, stop milking the jokes.

Ok, so here's my $0.02 - atleast for functions there's no naming
problem
when the name starts with uppercase E but for macros - remember the
big, green, ...(thanks goes to Chris Torek & Stan Milam for taking this
up at some other thread :) ).

Nov 15 '05 #9
Suman wrote:

Netocrat wrote:
[snipped...]
Come on everyone, stop milking the jokes.


Ok, so here's my $0.02 - atleast for functions there's no naming
problem
when the name starts with uppercase E but for macros - remember the
big, green, ...(thanks goes to Chris Torek & Stan Milam for taking this
up at some other thread :) ).


Except that if errno.h includes:
#define EBYGUM 666

If you then try:
#include <errno.h>
void EBYGUM(void)
{
}

The function definition will be expanded to:
void 666(void)
{
}

Which is obviously invalid.

So you've got to avoid names reserved for macros in your function names,
variable names, struct names etc (deliberately incomplete list)
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Nov 15 '05 #10
> From: Clark S. Cox III <cl*******@gmail.com>
What a cheesy thing to say. :-)
That's just full of holes.

They can't make jokes like that in Iraq, it upsets the Kurds.

Wow, this thread has gone whey off topic.


We've had the Kurds and the whey,
we need a spider to scare the joke away!
(We already scared the student away, I hope!)
Nov 15 '05 #11
"Robert Maas, see http://tinyurl.com/uh3t" wrote:
From: Clark S. Cox III <cl*******@gmail.com>
> What a cheesy thing to say. :-)
That's just full of holes.
They can't make jokes like that in Iraq, it upsets the Kurds.

Wow, this thread has gone whey off topic.


We've had the Kurds and the whey,
we need a spider to scare the joke away!
(We already scared the student away, I hope!)


Too late. The cannibalistic Miss Muffet has already eaten the
Kurds and whey. Which is Tuff etting.

--
"A man who is right every time is not likely to do very much."
-- Francis Crick, co-discover of DNA
"There is nothing more amazing than stupidity in action."
-- Thomas Matthews
Nov 15 '05 #12

CBFalconer wrote:

"If I knew then what I know today, I would still have invaded
Iraq. It was the right decision" - G.W. Bush, 2004-08-02


Thanks, Chuck; it's good to see someone appreciates
our Dear Leader. And last night we learned that it
was *still* the right decision.

Perhaps you should add another recent quote from the
Greatest American of the 21st century: "I think about
Iraq every day, every day!"

Think about it! Even on Saturdays and Sundays, he thinks
about Iraq. He was too modest to admit it, but I'm sure
some days he thinks about Iraq 2 or 3 times.

(And he's a busy man: I read in an Atlantic Monthly article
that before the war, the representative of several NGO's
was denied a meeting about humanitarian planning, because
"the President had already spent 20 minutes on that.")

"Our God is bigger than their God." Go Yanks!

James

Nov 15 '05 #13
"uma676" <um*************@gmail-dot-com.no-spam.invalid> escribió en el
mensaje news:d9**********@domitilla.aioe.org...
Hi all,
I want to know the differebces between function and macro in c
language. if anybody can tell me atleast 4 diff's. for which i will
be regrated.

Rgds,
Balaji


The main difference you want to know about macros vs functions is:

When you call a function your compiler enters a call-sequence (which takes
time) and allocates a new stack frame for that function (whcih takes text
stack space) so that the function's body can be executed. After it's done
you enter a returning-sequence phase (which takes time).

A macro does not need anything of the above, because it's preprocessor's job
to expand a macro, it's only about text replacement, not about compiler
stuff or code-generating issues. So you don't expend time and space doing
what a function would need in order to be executed.

That makes functions and macros completely different even if the result of
using both is, in some cases, the same. One must know it's suitable to use
one or the other. For instance: you can't point a pointer to a macro, but
you can use pointers to functions...

_______
Dienekes
Nov 15 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Rex_chaos | last post by:
Hi all, Here is a std::vector containing some std::complex<double>. I would like to take the amplitude of the complex array. i.e. v = amp of v = I try a template function but didn't work ...
4
by: MS | last post by:
Just a general question here re VBA. Can anyone explain the differences between "!" and "." when refering to a control? eg Me!TxtBox and Me.TxtBox. What is difference between "+" and "&"...
16
by: Kevin Zhou | last post by:
The question is "define a macro swap(t,x,y) that interchanges two arguments of type t". What does it mean? what are arugments of a type? I can't find an explanation in the book.
10
by: O Plameras | last post by:
Are there differences in terms of functionality of, #define and typedef ? By the above I mean any instance when the outcome obtained by running two versions (1) and (2) below of C codes...
9
by: Let_Me_Be | last post by:
Hi all, I'm developing a small defensive programming toolkit for my own projects. So, here are my questions. 1) Is it possible to move from something like this: SAFECALL(foo();) to __safecall...
13
by: Henry Townsend | last post by:
I hope this is on-topic in c.l.c - it's about the C preprocessor more than the language per se, more generally about the K&R behavior, and most specifically about the Sun cpp which is why I've...
6
by: jason | last post by:
Hi, I learned my lesson about passing pointers, but now I have a question about macros. Why does the function work and the MACRO which is doing the same thing on the surface, does not work in...
0
by: Taxman | last post by:
Windows XP, MS Office Excel 2003 If the tasks, I’m trying accomplish have been addressed previously (separately or in combination). Please, provide the links or keyword search to find them. I’ve...
19
by: Taras_96 | last post by:
Hi all, A poster at http://bytes.com/forum/thread60652.html implies that using strtoupper in transform doesn't work because ctype.h may define strtoupper as a macro: "The problem is that most...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.