Does LuaBind recognize inline functions?

View: New views
4 Messages — Rating Filter:   Alert me  

Does LuaBind recognize inline functions?

by Secretive Loon :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

It seems a silly question to me but it's the only conclusion I have left. My compiler gives the error:
Error 3 error C2065: 'AI_GetSinglePlayer' : undeclared identifier

for the line of code:
luabind::module( GetLua() ) [
luabind::def("AI_GetSinglePlayer", AI_GetSinglePlayer)
];

for the function:
inline CBasePlayer *AI_GetSinglePlayer()
{
if ( gpGlobals->maxClients > 1 )
{
return NULL;
}
return UTIL_GetLocalPlayer();
}

with the prototype/declaration:
inline CBasePlayer *AI_GetSinglePlayer( void );

Each piece of code is in a separate file. Intellisense goes to the declaration if I right-click and select "Go to Declaration", so it knows it's there. If I'm wrong about the inline functions, and I hope I am, what else could I be doing wrong here? The same code worked fine for a function with the same scope but wasn't inline. All input is appreciated.


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
luabind-user mailing list
luabind-user@...
https://lists.sourceforge.net/lists/listinfo/luabind-user

Re: Does LuaBind recognize inline functions?

by James Porter-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Secretive Loon wrote:
> Each piece of code is in a separate file. Intellisense goes to the
> declaration if I right-click and select "Go to Declaration", so it knows
> it's there. If I'm wrong about the inline functions, and I hope I am,
> what else could I be doing wrong here? The same code worked fine for a
> function with the same scope but wasn't inline. All input is appreciated.

There are two problems here:

1) You can't use an inline function if its definition isn't in the
current translation unit.

2) Why are you trying to inline the function? Luabind wouldn't be able
to use the function were inline-only (the "inline" keyword is just a
guideline), since the code for the function wouldn't necessarily exist
in the binary at all.

- Jim


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
luabind-user mailing list
luabind-user@...
https://lists.sourceforge.net/lists/listinfo/luabind-user

Re: Does LuaBind recognize inline functions?

by Thomas Nelson-10 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

You didn’t mention what compiler you are using, but “inline” is usually just a suggestion to the compiler. 

 

Luabind works through pointers to functions. An inline function has no address since it is expanded in place.

 

I should warn you though that placing the implementation of an inline function in a separate compilation unit (.cpp) can lead to unpredictable results.  One thing you might try is to remove your prototype and replace it with the implementation in your header.

--
Thomas Nelson  tdark@... 
--------------------------------------------------------------
"If you still have gas, you're not lost".
- French explorer Pierre Frontage.
(M.Frontage was so influential in the exploration of North America many roads are still named after him.)


From: Secretive Loon

 

It seems a silly question to me but it's the only conclusion I have left. My compiler gives the error:

Error  3          error C2065: 'AI_GetSinglePlayer' : undeclared identifier   

 

for the line of code:

luabind::module( GetLua() ) [

                      luabind::def("AI_GetSinglePlayer", AI_GetSinglePlayer)

          ];

 

for the function:

inline CBasePlayer *AI_GetSinglePlayer()

{

          if ( gpGlobals->maxClients > 1 )

          {

                      return NULL;

          }

         

          return UTIL_GetLocalPlayer();

}

 

with the prototype/declaration:

inline CBasePlayer *AI_GetSinglePlayer( void );

 

Each piece of code is in a separate file. Intellisense goes to the declaration if I right-click and select "Go to Declaration", so it knows it's there. If I'm wrong about the inline functions, and I hope I am, what else could I be doing wrong here? The same code worked fine for a function with the same scope but wasn't inline. All input is appreciated.

 


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
luabind-user mailing list
luabind-user@...
https://lists.sourceforge.net/lists/listinfo/luabind-user

Re: Does LuaBind recognize inline functions?

by Secretive Loon :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ah. You're absolutely right. I forgot that the code wouldn't be in the binary. Thank you very much :)
------------------------------------------------------------------------------

_______________________________________________
luabind-user mailing list
luabind-user@...
https://lists.sourceforge.net/lists/listinfo/luabind-user