Raised This Month: $319 Target: $400
 79%   Almost there!

[ANY] '#file' and what it does


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
IQuitTF2AndYouShouldToo
( ͡ ͜ʖ ͡)
Join Date: Dec 2011
Old 04-04-2019 , 16:47   [ANY] '#file' and what it does
Reply With Quote #1

I just discovered this for the first time in use in a plugin by JugadorXEI, where he had the following bit of code under his #pragma lines:
#file "Rebalanced Fortress 2"

Initially I was confused as to what #file did, until I tried compiling the plugin.

Normally, without the use of #file "nameofplugin", the compile.exe window will print out something similar to the following for errors/warnings:
C:\Coding\scripting\exampleplugin.sp(1) : warning 219: etcetera.

With the addition of #file "nameofplugin" to your plugin, compiling it with compile.exe will show the following for errors/warnings instead:
nameofplugin(1): warning 219: etcetera

Here's an image showing the difference in output:


I don't know if #file does anything else aside from this. Please, do tell if it does. As well, in regards to directives that I don't know the functionality of, there's also #assert, #emit and #error. Don't know what they do.

Last edited by IQuitTF2AndYouShouldToo; 04-05-2019 at 15:12. Reason: The syntax highlighting colors I use are from my personal ST3 Syntax Highlighting
IQuitTF2AndYouShouldToo is offline
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 04-04-2019 , 17:04   Re: [ANY] '#file' and what it does
Reply With Quote #2

oh lord this makes me nut so hard. Error logs have always bugged me for how messy they are and this helps that a lot.
__________________
Retired, find me at: https://drixevel.dev/
Drixevel is offline
Silvers
AlliedModders Donor
Join Date: Aug 2010
Location: SpaceX
Old 04-04-2019 , 17:08   Re: [ANY] '#file' and what it does
Reply With Quote #3

I've always hated the full path being part of the error messages. Why has this been hush hush for so long?
__________________
Silvers is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 04-05-2019 , 11:25   Re: [ANY] '#file' and what it does
Reply With Quote #4

What happens when you have
'#file "etc"'
within a file that you're including?
Mitchell is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine
Old 04-09-2019 , 08:28   Re: [ANY] '#file' and what it does
Reply With Quote #5

Personally, I like default behaviour, because you can see there a version number of your plugin (if you care about beautiful and correct folder structure of your plugins, of course).
Otherwise, it's impossible due to the fact dev. team refused request about adding version number to debug log.
Sometimes it's become very useful kind of info.

Also, you can indirectly see the person, who compiled the plugin (if you have several admins who care about plugins update).

BTW, 404UNF, thanks for info.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch)
[My plugins] [My tools] [GitHub] [Articles] [Donate]

Last edited by Dragokas; 04-09-2019 at 08:30.
Dragokas is offline
Timocop
AlliedModders Donor
Join Date: Mar 2013
Location: Germany
Old 04-09-2019 , 11:03   Re: [ANY] '#file' and what it does
Reply With Quote #6

Quote:
Originally Posted by Silvers View Post
I've always hated the full path being part of the error messages. Why has this been hush hush for so long?
Its always been there, since Small/Pawn. Same with #line. #file/#line is used for debug metadata to make stack traces more readable. (stored inside .smx .dbg.files and .dbg.lines)
As for the full path, its just easier to read. Imagne having alot of servers with alot of different plugins. If the stack trace only printed filenames you will have a hard time, especially includes. Also its usefull for automated tools.

Missusing #file/#line may cause confusion and generates unreadable stack traces. For example if the user renames the source file. It should never be used manualy, there is no reason why you should realy.

Quote:
Originally Posted by Dragokas View Post
Personally, I like default behaviour, because you can see there a version number of your plugin
#file has nothing todo with the plugin verison. It just groups which section of the source is part of what file.
__________________
Timocop is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine
Old 04-09-2019 , 11:52   Re: [ANY] '#file' and what it does
Reply With Quote #7

Quote:
Originally Posted by Timocop View Post
#file has nothing todo with the plugin verison. It just groups which section of the source is part of what file.
Yes, that's why I added a notice:
Quote:
(if you care about beautiful and correct folder structure of your plugins, of course).
... that include version number.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch)
[My plugins] [My tools] [GitHub] [Articles] [Donate]

Last edited by Dragokas; 04-09-2019 at 11:52.
Dragokas is offline
Timocop
AlliedModders Donor
Join Date: Mar 2013
Location: Germany
Old 04-10-2019 , 10:50   Re: [ANY] '#file' and what it does
Reply With Quote #8

W-why does everyone keep assuming my name!?


Quote:
Originally Posted by 404UNF View Post
Is there really a #line?
Yep. Im too lazy to search where #line is actualy located in the SourcePawn github files.
But you can find all compiler (Small/Pawn/SourcePawn) keywords on my BasicPawn github: https://github.com/Timocop/BasicPawn...dater.vb#L5078

Quote:
Originally Posted by 404UNF View Post
all it does is change what's shown in compile.exe
And in the error stack trace. Depends where you put it.

Code:
] sm plugins refresh
L 04/10/2019 - 16:08:49: [SM] Exception reported: Lmao notin here
L 04/10/2019 - 16:08:49: [SM] Blaming: ee0fc772-2f79-4c6c-b0ae-b13bbc971c57.smx
L 04/10/2019 - 16:08:49: [SM] Call stack trace:
L 04/10/2019 - 16:08:49: [SM]   [0] ThrowError
L 04/10/2019 - 16:08:49: [SM]   [1] Line 18, Externets epic plugin!::OnPluginStart
L 04/10/2019 - 16:08:49: [SM] Unable to load plugin "ee0fc772-2f79-4c6c-b0ae-b13bbc971c57.smx": Error detected in plugin startup (see error logs)
[SM] The plugin list has been refreshed and reloaded.
PHP Code:

#define DEBUG

#define PLUGIN_NAME           "My plugin"
#define PLUGIN_AUTHOR         ""
#define PLUGIN_DESCRIPTION    ""
#define PLUGIN_VERSION        "1.0"
#define PLUGIN_URL            ""

#file "Externets epic plugin!"

#include <sourcemod>
#include <sdktools>

#pragma semicolon 1

public Plugin myinfo =
{
    
name PLUGIN_NAME,
    
author PLUGIN_AUTHOR,
    
description PLUGIN_DESCRIPTION,
    
version PLUGIN_VERSION,
    
url PLUGIN_URL
};

public 
void OnPluginStart()
{
    
ThrowError("Lmao notin here");

Using #file/#line will definilty break BasicPawn's/SPEdit's (And probably other editors) error highlighting. So i doubt it will make you life easier using it with all those risks just for having a nice name in the compiler window


__________________

Last edited by Timocop; 04-10-2019 at 10:55.
Timocop is offline
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

Forum Jump


All times are GMT -4. The time now is 07:36.


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