Skip to main content
gamedev.net
🔒 Locked

C++ '_inline' problem. Please Help!!!

Started by Antoxa Dec 7, 2001 at 1:11 PM 4 replies 150+ views
Original Post
Antoxa
Antoxa
Why is this code compiled as an independent function not as ''inline'' instructions ? __inline int fixMul (int a, int b) { __asm { xor edx, edx mov eax, ' Target=_Blank>Link
I love games!
Spiral
Spiral
Try using

__forceinline int fixMul()

instead of

__inline int fixMul()


From MSDN:

quote:

inline

function_declarator; // C++ Specific

__inline

function_declarator;// Microsoft Specific

__forceinline

function_declarator;// Microsoft Specific

The inline and __inline keywords allow the compiler to insert a copy of the function body into each place the function is called. The insertion occurs only if the compiler's cost/benefit analysis show it to be profitable. The __forceinline keyword overrides the cost/benefit analysis and relies on the judgement of the programmer instead. Exercise caution when using __forceinline. Indiscriminate use of __forceinline can result in larger code with only marginal performance gains or, in some cases, even performance losses (due to increased paging of a larger executable, for example).



[EDIT] - i assume you're using MSVC as you are using __inline and __asm.

Edited by - Spiral on December 7, 2001 2:22:06 PM
--------------------Go Stick Your Head In A Pig
Antoxa
Antoxa
Yes, I''m using MSVC!
But, frankly speaking, i''ve tried to use _forceinline
it doesn''t help
But, you know, I don''t need this stupid precompiled
''
push a
push b
call fixMul
''
I love games!
Spiral
Spiral
Are you using 2 underscores before the forceinline?

_forceinline is WRONG
__forceinline is RIGHT
--------------------Go Stick Your Head In A Pig
burp
burp
You shouldn't be modifying the stack, on a inline asm function, it should look something like this...

    
//inline int FixMul(unsigned a, unsigned b) edit :)

inline unsigned FixMul(unsigned a, unsigned b)
{
__asm
{
mov eax,a
mul b
}
}


MSVC will only inline this in a release version!

Edited by - burp on December 7, 2001 5:56:28 PM

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.