Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


macros vs functions

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Mon Apr 07, 2008 7:45 pm    Post subject: macros vs functions Reply with quote

This is something really simple. But I just learned macros (=P), and I was thinking if I should use them if I were to make a REALLY SIMPLE calculator. Like if they use less memory than functions do or something. Like

Code:

#define mult(z) ((x) * (y))


or...

Code:

int mult(int x, int y)
{
    return x*y;
}

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Mon Apr 07, 2008 7:51 pm    Post subject: Reply with quote

Macros are better for speed, but increase the size.
Functions are better for size, but decrease the speed slightly due to all the push/pop/call stuff.

Also, if it is an extremely small macro like above, the macro would take less space than the function.


Last edited by Flyte on Mon Apr 07, 2008 7:51 pm; edited 1 time in total
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Mon Apr 07, 2008 7:51 pm    Post subject: Reply with quote

when u call a function your pushing information onto the stack, doing your calculations then poping them off the stack (i think, correct me if im wrong)

while a definition is just replacing the word defined, with the code that you have as the definition.

So definitions for smaller procedures such as multiplications would probly be more benificial.

Correct me if im wrong, its just general computing knowledge so im not completely sure.

Edit: dam, flyte beat me to it Razz, by a couple seconds.

_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites