473,397 Members | 2,084 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.

macro and function

HI.In what circumstances we should use a macro and when we should use a
function? If we use macro then will the size of the executable
increase?Thanks for help.

Eric

Oct 19 '06 #1
4 1647
di**********@yahoo.com wrote:
HI.In what circumstances we should use a macro and when we should use a
function?
Is there anything wrong with the thread started yesterday and still very
much active, first post <eh**********@usenet02.sei.cmu.edu>, subject
inline functions vs. macros?

Richard
Oct 19 '06 #2
di**********@yahoo.com said:
HI.In what circumstances we should use a macro and when we should use a
function?
If in doubt, use a function.
If we use macro then will the size of the executable
increase?
Probably. It depends on the macro, how you use it, how often you use it, and
how astounding your compiler is.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Oct 19 '06 #3
In article <11**********************@b28g2000cwb.googlegroups .com>,
<di**********@yahoo.comwrote:
>HI.In what circumstances we should use a macro and when we should use a
function?
macro: if you need the result at compile time, or if you
need to "stringize" something, or if you need to splice
together parts of a name to arrive at a new preprocessor macro name
whose value is required, or if you need to construct new syntaxes
or if you need a form that needs to work over multiple types

>If we use macro then will the size of the executable
increase?
That's an implementation issue, and might depend on the precise
nature of the macro and upon the contexts it is used in or upon
the number of times it is used. Sometimes using macros might result
in smaller executables and sometimes it might result in larger executables.

Talking about the size of an executable is usually not particularily
useful. An executable might include debugging information, might
include library linkage information, might bother to "merge"
constant literals, might "unroll" loops for optimization, might
use a longer sequence of instructions rather than a shorter sequence
if the longer sequence would be more efficient, might contain
the same code compiled for multiple architectures, and so on.
--
I was very young in those days, but I was also rather dim.
-- Christopher Priest
Oct 19 '06 #4

"Richard Bos" <rl*@hoekstra-uitgeverij.nlwrote in message
news:45****************@news.xs4all.nl...
di**********@yahoo.com wrote:
>HI.In what circumstances we should use a macro and when we should use a
function?

Is there anything wrong with the thread started yesterday and still very
much active, first post <eh**********@usenet02.sei.cmu.edu>, subject
inline functions vs. macros?

Richard
The posters are probably taking the same class.
The second one probably didn't bother to check previous threads.
--
Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Software Reuse Project
Oct 19 '06 #5

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

Similar topics

25
by: Andrew Dalke | last post by:
Here's a proposed Q&A for the FAQ based on a couple recent threads. Appropriate comments appreciated X.Y: Why doesn't Python have macros like in Lisp or Scheme? Before answering that, a...
699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
7
by: Newbie_sw2003 | last post by:
Where should I use them? I am giving you my understandings. Please correct me if I am wrong: MACRO: e.g.:#define ref-name 99 The code is substituted by the MACRO ref-name. So no overhead....
8
by: lasek | last post by:
Hi...in some posts i've read...something about using macro rather then function...but difference ??. Best regards....
4
by: ApexData | last post by:
Hello 1- What is the AutoExec Macro? Is it the same thing as AutoKeys Macro? 2- I'm looking to Control Keys equally on startup for my entire app. I understand that the AutoKeys Macro is the...
12
by: Laurent Deniau | last post by:
I was playing a bit with the preprocessor of gcc (4.1.1). The following macros expand to: #define A(...) __VA_ARGS__ #define B(x,...) __VA_ARGS__ A() -nothing, *no warning* A(x) -x ...
5
by: Bill | last post by:
This database has no forms. I am viewing an Access table in datasheet view. I'd like to execute a macro to execute a function (using "runcode"). In the function, I'll reading data from the record...
14
by: amit.man | last post by:
Hello i need to write a MACRO function that look something like this """ do_somthing(); for(int i=0;i<100;i++) {do_something_else())} return(somthing_other_then_those()) // a double type """
33
by: Peng Yu | last post by:
Hi, __PRETTY_FUNCTION__ is a macro that gives function name, etc. I'm wondering if there is a macro to get the class name inside a member function. Thanks, Peng
16
by: mdh | last post by:
I have asked a few questions about Macros...and think what I have been missing ...and which all who have replied clearly understand...is that this is a Pre-processor action. Hopefully the above is...
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
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
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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.