The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
in vim how can i view the macro lakshmananindia UNIX for Advanced & Expert Users 2 10-25-2007 06:25 AM
Regarding #ident macro sarwan High Level Programming 1 10-06-2006 04:17 AM
USRSTACK macro jalburger HP-UX 1 12-03-2004 04:58 PM
VI Macro Problem Atama UNIX for Dummies Questions & Answers 1 05-16-2002 12:13 PM
macro on shell script ? inquirer UNIX for Dummies Questions & Answers 4 08-15-2001 10:31 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-30-2006
bankpro bankpro is offline
Registered User
  
 

Join Date: Jan 2006
Location: Mumbai
Posts: 43
macro

Can i define a macro for a function of 10 LOC.
  #2 (permalink)  
Old 01-30-2006
matrixmadhan matrixmadhan is online now Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,952
yes you can,

but i dont think there could be any such necessity for the same,

in case of function definition it is going to be one time and why do u need to have a macro for that,

macros are meant for substitution where u need to have many.

Code:
# include <stdio.h>

void fun();

# define ab void fun() { printf("fun\n"); }

int main()
{
   (void) fun();
   return 0;
}

ab
hope this helps, or could u please post your code ?
  #3 (permalink)  
Old 01-30-2006
bankpro bankpro is offline
Registered User
  
 

Join Date: Jan 2006
Location: Mumbai
Posts: 43
macro1

thanks matrixmadan.


actually we want to overcome the time that is lost , a function
takes while visiting the stack twice.
  #4 (permalink)  
Old 01-30-2006
matrixmadhan matrixmadhan is online now Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,952
i am afraid I didnt get your point exactly,

did u mean, popping and pushing function address and re-iterating program counter in stack trace ?

if that is so, then having a macro will not have any effect on the above,
as macro substitution would take place at the pre-compilation stage itself,

then goes compilation, linking, executing.
No way the time counters represented above would have an effect

If I had understood wrongly, please get me the correct point.

Thanks.
  #5 (permalink)  
Old 01-31-2006
bankpro bankpro is offline
Registered User
  
 

Join Date: Jan 2006
Location: Mumbai
Posts: 43
no

actually,
instead of calling a function we want a macro to do the job.
i.e can we have a function in the form of a macro.
e.g

#define fun(args....)
/*code for macro */
/*about 10 loc */
main()
{
....
....
....
fun(....);
....
}
  #6 (permalink)  
Old 01-31-2006
matrixmadhan matrixmadhan is online now Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,952
then in such case,

make use of inline functions they get expanded in pre-compilation itself
similiar to macros.

But make sure that the function quoted as inline should not be a heavy-loaded which would drastically bring down the performance of the program.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:47 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0