SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 26/02/2020, 07:59 PM   #1
pollo97
Big Clucker
 
pollo97's Avatar
 
Join Date: Sep 2011
Location: Italy
Posts: 82
Reputation: 4
Default #include doesn't include

Hi to everyone, i'm creating a project using the modular programming technique and I got this error:

Code:
core/systems/connection/login/core.pwn(6) : error 017: undefined symbol "InitializeForLogin"
Now there are two files, one is core.pwn and the other is functions.pwn
In the main.pwn I included the files in this way:

Code:
... other #include

#include "core/systems/connection/login/core.pwn"
#include "core/systems/connection/login/functions.pwn"
The code of core.pwn:
Code:
#include <YSI_Coding\y_hooks>

public OnPlayerConnect(playerid)
{
	InitializeForLogin(playerid);
    .... 
}
The code of functions.pwn:
Code:
InitializeForLogin(playerid)
{
...
}
I tried to move the definition of "InitializeForLogin(playerid)" after "core" inclusion in the main, like this:
Code:
#include "core/systems/connection/login/core.pwn"
InitializeForLogin(playerid)
{
...
}
And works fine. So it seems is not including functions.pwn

What's wrong?



UPDATE:
I tried to modify this inclusion:
Code:
#include "core/systems/connection/login/functions.pwn"
Into:
Code:
#include "corewrong/systems/connection/login/functions.pwn"
corewrong folder doesn't exist and the compiler give me the error:
Code:
fatal error 100: cannot read from file: "corewrong/systems/connection/login/functions.pwn"
And it's fine, but when I change the file name with a wrong one, i get no error of "cannot read from file":
Code:
#include "core/systems/connection/login/wrong.pwn"
So it's seems the compiler isn't opening the file, I tried using either default compiler and Zeex's version.

Last edited by pollo97; 27/02/2020 at 10:31 AM.
pollo97 is offline   Reply With Quote
Old 27/02/2020, 10:35 AM   #2
insus100
Big Clucker
 
insus100's Avatar
 
Join Date: Jun 2017
Location: Pa k kieres saber eso jaja salud2
Posts: 98
Reputation: 3
Default Re: #include doesn't include

Try
PHP Code:
#include "/core/systems/connection/login/functions.pwn 
__________________

Join Discord!

insus100 is offline   Reply With Quote
Old 27/02/2020, 11:32 AM   #3
pollo97
Big Clucker
 
pollo97's Avatar
 
Join Date: Sep 2011
Location: Italy
Posts: 82
Reputation: 4
Default Re: #include doesn't include

Quote:
Originally Posted by insus100 View Post
Try
PHP Code:
#include "/core/systems/connection/login/functions.pwn 
It's working but why?
If I change also the core's inclusion in this way:
Code:
#include "/core/systems/connection/login/core.pwn"
#include "/core/systems/connection/login/functions.pwn"
It gives me the same error of before
Code:
error 017: undefined symbol "InitializeForLogin"
I'm confused :/


UPDATE:
I finally solved using this guide.
Code:
#include "core\systems\connection\login/core.pwn"
#include "core\systems\connection\login/functions.pwn"
The inclusion formatted in this way worked.

Last edited by pollo97; 27/02/2020 at 01:45 PM.
pollo97 is offline   Reply With Quote
Old 27/02/2020, 01:43 PM   #4
Nero_3D
High-roller
 
Nero_3D's Avatar
 
Join Date: Jun 2007
Location: Germany
Posts: 2,840
Reputation: 671
Default Re: #include doesn't include

you could create a list file (-l in the compiler option) and see what the preprocessor does

but I think your problem is that you use forward slashes and the default compiler
Quote:
Originally Posted by ColeMiner View Post
I suspect this is something to do with the length:

pawn Code:
_inc_files/scripts/staff/genera

As the include-guard would be called when using forward slashes (not a valid name, but that's the problem with forward slashes) is 31 characters. When using "\" the separators are correctly identified and you get this:

pawn Code:
_inc_general

Thus, if you have another file called "general" in another folder, this one won't get included because the compiler thinks it already has been. This sounds like the best candidate for the problem (ignore what I started saying about length) - it MAY crash if you include code here that is needed, but it doesn't get included because of the mix-up with include guards.

I don't always recommend using "\" for exactly this reason - which to use varies by use-case. In your case you may want to instead use "/" since it worked anyway (just be aware of long directory chains).

Zeex's compiler doesn't automatically generate include guards so this won't be a problem there, but that can cause other issues if your files don't contain explicit include guards as required.
Nero_3D is offline   Reply With Quote
Reply

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
YouTube include doesn't work NeXoR Scripting Help 0 01/04/2016 09:19 PM
Clickable Textdraws dont work when i put #include <YSI\y_iterate> and #include <YSI\y_areas> ervinmasic Scripting Help 20 24/01/2016 09:01 PM
PAWN compiler doesn't include all files Callum98 Scripting Help 5 27/02/2015 06:29 PM
Include doesn't works Nightmare[TR] Scripting Help 3 20/06/2012 09:41 AM
Making an OnFilterScriptInit in an include without adding anything in the .pwn exepct the #include r3k1lLz_ Help Archive 6 06/01/2011 06:49 AM


All times are GMT. The time now is 10:59 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.