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

[ANY] '#file' and what it does


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
404UserNotFound
BANNED
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 404UserNotFound; 04-05-2019 at 15:12. Reason: The syntax highlighting colors I use are from my personal ST3 Syntax Highlighting
404UserNotFound 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.
Drixevel is offline
Silvers
SourceMod Plugin Approver
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
404UserNotFound
BANNED
Join Date: Dec 2011
Old 04-04-2019 , 20:17   Re: [ANY] '#file' and what it does
Reply With Quote #4

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?
I've known about #file for a while (as a result of looking at a list of directives for my sublime text 3 syntax highlighting), just never knew what it did. Never thought to test it either.

Last edited by 404UserNotFound; 04-10-2019 at 22:17.
404UserNotFound is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 04-05-2019 , 11:25   Re: [ANY] '#file' and what it does
Reply With Quote #5

What happens when you have
'#file "etc"'
within a file that you're including?
Mitchell is offline
404UserNotFound
BANNED
Join Date: Dec 2011
Old 04-05-2019 , 15:00   Re: [ANY] '#file' and what it does
Reply With Quote #6

Quote:
Originally Posted by Mitchell View Post
What happens when you have
'#file "etc"'
within a file that you're including?
I assume it would function identically. If there are any errors within the .inc, I assume the compiler would do the same as with a plugin and just show the name you've supplied the #file directive instead of the full path to the scripting/include folder where your include is.

Last edited by 404UserNotFound; 04-10-2019 at 22:17.
404UserNotFound is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 04-09-2019 , 08:28   Re: [ANY] '#file' and what it does
Reply With Quote #7

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 & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [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 #8

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 on fire
Old 04-09-2019 , 11:52   Re: [ANY] '#file' and what it does
Reply With Quote #9

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 & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

Last edited by Dragokas; 04-09-2019 at 11:52.
Dragokas is offline
404UserNotFound
BANNED
Join Date: Dec 2011
Old 04-09-2019 , 16:53   Re: [ANY] '#file' and what it does
Reply With Quote #10

Quote:
Originally Posted by Timocop View Post
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.

#file has nothing todo with the plugin verison. It just groups which section of the source is part of what file.
Is there really a #line? My syntax highlighting lacks it and I don't recall reading it in the list of directives in sourcemod's source code.

I also just asked in the SourceMod Discord what all #file does, and all it does is change what's shown in compile.exe, so me using it in some recent plugins and putting it into the updated SPEdit templates as part of my PR on JulienKluge's repo is all good. You had me worried for a second there when I read your post, Timo

Last edited by 404UserNotFound; 04-10-2019 at 22:16.
404UserNotFound 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 06:00.


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