use of __fastcall

1 view
Skip to first unread message

AnishK

unread,
Jan 8, 2009, 1:25:08 AM1/8/09
to libnepal
hi friends

what is the use of __fastcall in C++ code? I have found it while
trying to read a friends code.



thank u

Prasanna Gautam

unread,
Jan 8, 2009, 1:49:17 AM1/8/09
to libn...@googlegroups.com
I've never used it (maybe because it's microsoft specific) but it seems to be an optimization for 32 bit systems that lets the compiler load the arguments in registers whenever possible.  This link might be useful to decide if it's useful or not.
http://blogs.msdn.com/larryosterman/archive/2005/10/10/479278.aspx
Here's the documentation. Seems clear enough that I don't find it necessary to rewrite here.
http://msdn.microsoft.com/en-us/library/6xa169sk(VS.80).aspx

I'd just ignore this call because
1. It's specific to a system
You can set it at compile time to use fastcall for windows however using preprocessor directives if you need to.
2. It doesn't seem to provide significant boost unless it's the application seriously requires such optimizations. You'll know when that's the case but it's easy to overdo it.
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is my signature. You might have seen it elsewhere too but this is mine.

simplepro...@gmail.com

unread,
Jan 8, 2009, 1:49:44 AM1/8/09
to libn...@googlegroups.com
ok looks like __fastcall helps the code run faster.

is it so? thank u

AnishK

unread,
Jan 8, 2009, 1:58:31 AM1/8/09
to libn...@googlegroups.com
prasanna thanks ok i will read but if i have function like this
void __fastcall helpermsg(int a) { }
i think it copies a in register but how helpermsg is faster copies
to the register?

AnishK

unread,
Jan 8, 2009, 2:24:19 AM1/8/09
to libn...@googlegroups.com

http://bcbjournal.org/articles/vol4/0004/When_to_use___fastcall.htm?PHPSESSID=955ee1f347b63f7c4ecc779c5c8aae28

says that __fastcall is not fast always and actually says not to use it. this is the problem with old code. now i
need to replace them.

nepbabu.cx

unread,
Jan 8, 2009, 2:27:29 AM1/8/09
to libn...@googlegroups.com
Hi Anish,

AnishK wrote:
> prasanna thanks ok i will read but if i have function like this
> void __fastcall helpermsg(int a) { }
> i think it copies a in register but how helpermsg is faster copies
> to the register?

It helps most of the time if you can profile the code and see it
yourself Anish :)

Prasanna Gautam

unread,
Jan 8, 2009, 3:05:47 AM1/8/09
to libn...@googlegroups.com

This would be useful I guess.Beware: I haven't tried it  http://blogs.msdn.com/msdnmagazine/archive/2008/04/07/8357566.aspx


Reply all
Reply to author
Forward
0 new messages