AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [ANY] '#file' and what it does (https://forums.alliedmods.net/showthread.php?t=315375)

404UserNotFound 04-04-2019 16:47

[ANY] '#file' and what it does
 
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:
https://cdn.discordapp.com/attachmen...65/unknown.png

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.

Drixevel 04-04-2019 17:04

Re: [ANY] '#file' and what it does
 
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.

Silvers 04-04-2019 17:08

Re: [ANY] '#file' and what it does
 
I've always hated the full path being part of the error messages. Why has this been hush hush for so long?

404UserNotFound 04-04-2019 20:17

Re: [ANY] '#file' and what it does
 
Quote:

Originally Posted by Silvers (Post 2646337)
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.

Mitchell 04-05-2019 11:25

Re: [ANY] '#file' and what it does
 
What happens when you have
'#file "etc"'
within a file that you're including?

404UserNotFound 04-05-2019 15:00

Re: [ANY] '#file' and what it does
 
Quote:

Originally Posted by Mitchell (Post 2646420)
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.

Dragokas 04-09-2019 08:28

Re: [ANY] '#file' and what it does
 
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.

Timocop 04-09-2019 11:03

Re: [ANY] '#file' and what it does
 
Quote:

Originally Posted by Silvers (Post 2646337)
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 (Post 2646850)
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.

Dragokas 04-09-2019 11:52

Re: [ANY] '#file' and what it does
 
Quote:

Originally Posted by Timocop (Post 2646871)
#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.

404UserNotFound 04-09-2019 16:53

Re: [ANY] '#file' and what it does
 
Quote:

Originally Posted by Timocop (Post 2646871)
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 :P


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

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