Error when using special preprocessor-provided constants
Closed this issue · 4 comments
XenHat commented
Thanks for the updated binaries, I can script again!
I am having issues when using some special constants provided by the LSL Preprocessor, such as __AGENTID__
:
Would it be possible to treat them properly?
The few constants added by the preprocessor are the following:
-
__FILE__
- the full path to the script as it would appear in the include cache. The top script only uses its name. -
__LINE__
- the line of the current script where it is expanded; this starts at line 0 -
__SHORTFILE__
- the name of the current script without full file path -
__AGENTID__
- a string-encapsulated version of the agent's key who compiles the script -
__AGENTKEY__
- same as above, legacy version -
__AGENTIDRAW__
- a nonstring-encapsulated version of the agent's key who compiles the script -
__AGENTNAME__
- a string-encapsulated version of the agent's full name who compiles the script -
__ASSETID__
- a string-encapsulated version of the assetid of the current script; may return “NOT IN WORLD” or a nonstring-encapsulated null key in rare circumstances
Sei-Lisa commented
What preprocessor are you using and how do you expect it to receive e.g. your agent UUID?
The optimizer has options to set these macros; you can run the preprocessor through it, setting the values via the command line, and use the --preshow option to make it stop after preprocessing.
XenHat commented
I am using the same setup I have been using this whole time: Sublime Text, SublimeLinter3, my plugin and mcpp :)
Sei-Lisa commented
The other question remains, how do you expect it to receive e.g. your agent UUID?
`__FILE__` and `__LINE__` are standard and mcpp already makes those work. The rest are Firestorm-exclusive.
`__SHORTFILE__` needs to be generated from the file somehow. The Linux utility `basename` could do that.
So, you could create a bash file like this:
```bash
#!/bin/bash
my_uuid="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
my_name="xxxxx"
mcpp -D__AGENTID__=\""$my_uuid"\" -D__AGENTKEY__=\""$my_uuid"\" -D__AGENTIDRAW__="$my_uuid" -D__AGENTNAME__="$my_name" -D__ASSETID__="NOT IN WORLD" -D__SHORTFILE__="$(basename "$1")" "$1" -o "$2"
```
and run it instead of running mcpp directly, with the first argument being the input file and the second argument the output file. Add any other mcpp options you're using where appropriate.
XenHat commented
Ooh clever. I didn't think of that. I suppose that is a better option than
making the linter ignore it, too. I'll add some code to my linter to see if
I can work around this in a fairly easy to use way.