Raised This Month: $51 Target: $400
 12% 

Function Prototypes do not Match


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Gotank65
Junior Member
Join Date: Jun 2006
Location: Bucks
Old 07-26-2016 , 22:09   Function Prototypes do not Match
Reply With Quote #1

I'm trying to get this plugin to compile, I've fixed most of the errors however I'm not sure what to do with these last few.

(I did NOT write this code, I am attempting to get the plugin to compile from an old plugin)


Here are the errors:
PHP Code:
// parts.inc(113) : error 100: function prototypes do not match
// parts.inc(121) : error 100: function prototypes do not match
// parts/BT_(ball_trail).inc(26) : error 100: function prototypes do not match
// parts/BT_(ball_trail).inc(31) : error 100: function prototypes do not match
//
// 4 Errors. 

Here is the file parts.inc
PHP Code:

HookPartEvent
(const String:hookName[], const String:partName[PART_NAME_LENGTH], const String:postfix[])
{
    
decl String:partFunctionName[MAX_NAME_LENGTH]
    
Format(partFunctionNameMAX_NAME_LENGTH"%s_Event_%s"partNamepostfix);
    new 
EventHook:functionx GetFunctionByName(INVALID_HANDLEpartFunctionName)
    if (
functionx != INVALID_FUNCTION)                                               <----    //  Line 113
    
{
        
HookEventEx(hookNamefunctionx)
    }

    
decl String:partPreFunctionName[MAX_NAME_LENGTH]
    
Format(partPreFunctionNameMAX_NAME_LENGTH"%s_Event_Pre%s"partNamepostfix);
    new 
EventHook:preFunction GetFunctionByName(INVALID_HANDLEpartPreFunctionName)
    if (
preFunction != INVALID_FUNCTION)                                          <----    // Line 121
    
{
        
HookEventEx(hookNamepreFunctionEventHookMode_Pre)
    }




And here is the BT_(ball_trail).inc file


PHP Code:
InitGame()
{
    
GetGameFolderName(GameFolderNamesizeof(GameFolderName))
    new Function:
initGameFunc
    MapFunction
(initGameFunc"Init")
    
I_Call_void_void(initGameFunc)                         <----    // Line 26
}

public 
BT_OnBallCreated(ballEntity)
{
    
I_Call_void_void(CreateBallTrailProc)            <----    // Line 31




I'm not exactly sure WHERE the prototypes are declared for this however, this code may be part of the issue:

PHP Code:
functag public I_void_void()
functag public I_void_i(i)

I_Call_void_void(I_void_void:functionx)
{
    if (
functionx != INVALID_FUNCTION)
    {
        
Call_StartFunction(INVALID_HANDLEfunctionx)
        
Call_Finish()
    }




The above code is part of it's own file but i don't know what is wrong with the prototypes like it says....


Also, the lines in the Parts.inc file are conditional statements soooo I'm confused how those have bad prototypes as well...

(I did NOT write this code, I am attempting to get the plugin to compile from an old plugin)

Please help, thanks!

Last edited by Gotank65; 07-26-2016 at 22:11.
Gotank65 is offline
Gotank65
Junior Member
Join Date: Jun 2006
Location: Bucks
Old 07-27-2016 , 03:45   Re: Function Prototypes do not Match
Reply With Quote #2

Ok, so i believe the main issue in the code is part of this line

PHP Code:
new EventHook:preFunction GetFunctionByName(INVALID_HANDLEpartPreFunctionName); 

And the other issue has to do with this line

PHP Code:
new EventHook:functionx GetFunctionByName(INVALID_HANDLEpartFunctionName); 

the function GetFunctionByName() should be returning a Function ID or "INVALID_FUNCTION"

based on this page: https://sm.alliedmods.net/new-api/fu...FunctionByName


However the code that says:

PHP Code:
new EventHook:functionx 

^^^^ This is what I am confused about and I believe it may be causing the problem based on what it says on this page:

https://sm.alliedmods.net/new-api/events/EventHook


I just don't know if "EventHook" can be used the way it is being used there

Either that or maybe GetFunctionByName() is not used the right way.


All I need to know is:

PHP Code:
new EventHook:functionx GetFunctionByName(INVALID_HANDLEpartFunctionName); 
^^^ What is wrong with this line???
Gotank65 is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 07-27-2016 , 05:38   Re: Function Prototypes do not Match
Reply With Quote #3

EventHook is a funcenum/typeset, so it should coerce to a Function fine. If you retag the return tag of GetFunctionByName to EventHook it seems to remove the error, but it's strange that you have to do it.
PHP Code:
new EventHook:functionx EventHook:GetFunctionByName(INVALID_HANDLEpartFunctionName); 
Can you post the CreateBallTrailProc and MapFunction functions as well?
__________________
Peace-Maker is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 07-27-2016 , 06:51   Re: Function Prototypes do not Match
Reply With Quote #4

Quote:
Originally Posted by Peace-Maker View Post
EventHook is a funcenum/typeset, so it should coerce to a Function fine. If you retag the return tag of GetFunctionByName to EventHook it seems to remove the error, but it's strange that you have to do it.
He's assigning a Function (the return of GetFunctionByName) to an EventHook, that's the opposite of EventHook coercing to Function.
Fyren is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 07-27-2016 , 07:22   Re: Function Prototypes do not Match
Reply With Quote #5

Quote:
Originally Posted by Fyren View Post
He's assigning a Function (the return of GetFunctionByName) to an EventHook, that's the opposite of EventHook coercing to Function.
You're right, I've been confused by the error line being reported falsely as the next code line.
That's why you should always use semicolons :B
__________________
Peace-Maker is offline
Gotank65
Junior Member
Join Date: Jun 2006
Location: Bucks
Old 07-27-2016 , 15:08   Re: Function Prototypes do not Match
Reply With Quote #6

Quote:
Originally Posted by Peace-Maker View Post
EventHook is a funcenum/typeset, so it should coerce to a Function fine. If you retag the return tag of GetFunctionByName to EventHook it seems to remove the error, but it's strange that you have to do it.
PHP Code:
new EventHook:functionx EventHook:GetFunctionByName(INVALID_HANDLEpartFunctionName); 
Can you post the CreateBallTrailProc and MapFunction functions as well?
Thank you, the plugin now fully compiles no problem.

My question is, will it still RUN correctly with the changes?

PHP Code:
new EventHook:functionx EventHook:GetFunctionByName(INVALID_HANDLEpartFunctionName); 
This line should do what the function was trying to do correct?

here is a screen cap of the function again:




Also, you asked for the CreateBallTrailProc and MapFunction functions

here is the MapFunction
PHP Code:
MapFunction(&Function:functionx, const String:functionName[])
      {
          
MapFunctionPrefix(functionxGameFolderNamefunctionName)
      } 
However, I could not find a clear instance for the CreateBallTrailProc function, here the word was only used 3 times and I searched all the files included with the plugin

here is the screen shot of its usage:




The only thing I did to fix the Other Error I was getting for prototypes was to change this code

PHP Code:
functag public I_void_void()
functag public I_void_i(i)

I_Call_void_void(I_void_void:functionx)
{
    if (
functionx != INVALID_FUNCTION)
    {
        
Call_StartFunction(INVALID_HANDLEfunctionx)
        
Call_Finish()
    }

into this code:


PHP Code:
functag public I_void_void()
functag public I_void_i(i)

I_Call_void_void(Function:functionx)
{
    if (
functionx != INVALID_FUNCTION)
    {
        
Call_StartFunction(INVALID_HANDLEfunctionx)
        
Call_Finish()
    }

notice the line

PHP Code:
I_Call_void_void(I_void_void:functionx
now reads

PHP Code:
I_Call_void_void(Function:functionx
I dont know if this is correct either, however, I guess I will find out if it works when I try to run the plugin on my server.

Please let me know if you see anything wrong!

Thanks again for the help!!

Last edited by Gotank65; 07-27-2016 at 15:11.
Gotank65 is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 07-27-2016 , 19:37   Re: Function Prototypes do not Match
Reply With Quote #7

Quote:
Originally Posted by Gotank65 View Post
PHP Code:
new EventHook:functionx EventHook:GetFunctionByName(INVALID_HANDLEpartFunctionName); 
This line should do what the function was trying to do correct?
Yes, it's the same thing, just semantically correct(er).

Quote:
Originally Posted by Gotank65 View Post
The only thing I did to fix the Other Error I was getting for prototypes was to change this code

PHP Code:
I_Call_void_void(I_void_void:functionx
now reads

PHP Code:
I_Call_void_void(Function:functionx
That's a proper change. The original intention of the code was to let the compiler verify if the called function has the proper prototype, but it suffers from the same problem as the other error. The author used some weird string lookup of functions and stores the function address in a "Function"-tagged variable. You'd need to explicitly retag the variable to the proper functag it expects, but that overrides the compiler's checks, so it won't help you anymore.

So another solution could be to declare the variables with the right tag the I_Call_void_void function expects:
PHP Code:
new I_void_void:initGameFunc 
and
PHP Code:
new I_void_void:CreateBallTrailProc 
instead of the "Function" tag.
But it wouldn't change anything in the code behavior ;)
__________________
Peace-Maker is offline
Reply



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

Forum Jump


All times are GMT -4. The time now is 03:00.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode