code34 248 Posted November 3, 2017 Hi, Just try to use this feature https://community.bistudio.com/wiki/preprocessFileLineNumbers adding a line in a helloworld sqf script preprocessed #line 2 "test" it seems its totaly fail silently the preprocess of the file, the preprocess content only containing {} after this. Does anyone know how to use it ? Is there a new syntax ? Share this post Link to post Share on other sites
Tajin 348 Posted November 3, 2017 What kind of command is "#line" supposed to be ? Share this post Link to post Share on other sites
h - 169 Posted November 3, 2017 #line probably should be explained in it's own article or something as it just confuses there: The way I understand it is that preprocessFileLineNumbers creates that keyword on the first line by itself, you can't add and don't need to add any in the file yourself as files preprocessed with it always return the line numbers (I guess BIS never thought to add that into their error handling to show the preprocess fails with 'additional' #lines..). What you can do is use the keyword as explained in the BIKI in functions that are not preprocessed, like putting this is the debug console: test = { #line 2 "wtf"; assert (1 > 2); }; test2 = { #line 2 "wtf"; if (count 2 > 1) then {}; }; When you call test you will get an error saying something like "file wtf, line 2, assertation failed" When you call test2 you will get an error saying something like "file wtf, line 2, generic error in expression" Seems to work only with called or spawned non-preprocessed code, not "with any script" as it says in the Biki idk, that's the only way I've been able to get that to work, thus the conclusion.. 1 Share this post Link to post Share on other sites
Dedmen 2604 Posted November 3, 2017 The preprocessor processes preprocessor macros/commands. If you insert a preprocessor command that doesn't exist it will just ignore it. #line doesn't exist. It's a compiler command that the preprocessor can output. The preprocessor doesn't take that as input. So no. It doesn't fail. And no. It has an effect. It processes the string correctly as it should and outputs the result. After the preprocessor preprocessed unpreprocessed scripts the postprocessor postprocesses the preprocessed scripts and the compiler processes the postprocessed scripts into processed code. 1 Share this post Link to post Share on other sites
code34 248 Posted November 3, 2017 3 hours ago, h - said: #line probably should be explained in it's own article or something as it just confuses there: The way I understand it is that preprocessFileLineNumbers creates that keyword on the first line by itself, you can't add and don't need to add any in the file yourself as files preprocessed with it always return the line numbers (I guess BIS never thought to add that into their error handling to show the preprocess fails with 'additional' #lines..). What you can do is use the keyword as explained in the BIKI in functions that are not preprocessed, like putting this is the debug console: test = { #line 2 "wtf"; assert (1 > 2); }; test2 = { #line 2 "wtf"; if (count 2 > 1) then {}; }; When you call test you will get an error saying something like "file wtf, line 2, assertation failed" When you call test2 you will get an error saying something like "file wtf, line 2, generic error in expression" Seems to work only with called or spawned non-preprocessed code, not "with any script" as it says in the Biki idk, that's the only way I've been able to get that to work, thus the conclusion.. i tried it but it doesnt work. It retuns a undefine variable error init.sqf compile "test.sqf"; sleep 2; call test2; test.sqf test = { #line 2 "wtf"; assert (1 > 2); }; test2 = { #line 2 "wtf"; if (count 2 > 1) then {}; }; Share this post Link to post Share on other sites
code34 248 Posted November 3, 2017 3 hours ago, dedmen said: The preprocessor processes preprocessor macros/commands. If you insert a preprocessor command that doesn't exist it will just ignore it. #line doesn't exist. It's a compiler command that the preprocessor can output. The preprocessor doesn't take that as input. So no. It doesn't fail. And no. It has an effect. It processes the string correctly as it should and outputs the result. After the preprocessor preprocessed unpreprocessed scripts the postprocessor postprocesses the preprocessed scripts and the compiler processes the postprocessed scripts into processed code. it seems it does more than that cause it has a side effet to break the preprocess file return. When i add #line 2 "string" anywhere into the sqf, it doesnt return any error, but the preprocessFileLineNumbers command return = {} instead of {#1 filename code}, that makes the code unusable. Share this post Link to post Share on other sites
h - 169 Posted November 3, 2017 Quote compile "test.sqf"; compile doesn't work like that, it compiles an expression, not a file. Instead use call compile loadFile "test.sqf" 1 Share this post Link to post Share on other sites
Dedmen 2604 Posted November 3, 2017 39 minutes ago, code34 said: i tried it but it doesnt work. It retuns a undefine variable error Of cause it does. "test" is most likely not a valid variable. Don't even know how SQF handles the dot. 33 minutes ago, code34 said: it seems it does more than that cause it has a side effet to break the preprocess file return. When i add #line 2 "string" anywhere into the sqf, it doesnt return any error, but the preprocessFileLineNumbers command return = {} instead of {#1 filename code}, that makes the code unusable. What exactly are you trying to do here? You could try #define TEST #line 1 "stuff" TEST That might work as preproc only does one pass. Share this post Link to post Share on other sites
code34 248 Posted November 3, 2017 44 minutes ago, dedmen said: Of cause it does. "test" is most likely not a valid variable. Don't even know how SQF handles the dot. What exactly are you trying to do here? You could try #define TEST #line 1 "stuff" TEST That might work as preproc only does one pass. i tried but it still send me errors , if you have a sample mission on git, already working im interested by. Share this post Link to post Share on other sites
code34 248 Posted November 3, 2017 to be more explicit, i want to add my own points like describe on this page: https://community.bistudio.com/wiki/preprocessFileLineNumbers #line 2 "myowndebugpoint" Share this post Link to post Share on other sites
Dedmen 2604 Posted November 3, 2017 4 hours ago, code34 said: to be more explicit, i want to add my own points like describe on this page: https://community.bistudio.com/wiki/preprocessFileLineNumbers #line 2 "myowndebugpoint" You have to add them after preprocessing.. You can just not preprocess your file and pass the content directly to "compile". 1 Share this post Link to post Share on other sites
metalman10 10 Posted November 3, 2017 No need to complicate all this. Use this instead /****************************************************** Script : Playuer Init Made For : Exile Mod || TGN Community Author : Metalman10 / 6IX Returns : ******************************************************/ waitUntil { !isNull (findDisplay 46) }; { _x params [ [ "_function", "" ], [ "_file", "" ], [ "_useState", false ] ]; private _code = compileFinal ( preprocessFileLineNumbers _file ); if ( _function isEqualTo "" || _file isEqualTo "" ) then { for "_x" from 0 to 15 do { diag_log format [ "WARNING! :: CHECK YOUR PLAYER INIT ! YOU HAVE MISSING PARAMS !", _function, _file ]; }; } else { if ( _useState isEqualTo false ) then { diag_log format [ "TGN DEBUG :: Function ( %1 | %2 ) use state is FALSE. File ignored.", _function, _file ]; } else { missionNamespace setVariable [ _function, _code]; }; }; true } count []; 1 Share this post Link to post Share on other sites
code34 248 Posted November 4, 2017 13 hours ago, dedmen said: You have to add them after preprocessing.. You can just not preprocess your file and pass the content directly to "compile". i just find it. That was a bit tricky but it seems to work(not totaly sure cause i m not familiar with those kind of thing. In fact default macro should work like this #line firstline "nameofthefile" so by default, should be something like this #line 1 __FILE__ i add this to my code to escape the sharp character to preprocessor, and rewrite the #line sequence #define DEBUG(sharp,name) sharp##line 0 name and introduce it like this in my oop object PUBLIC FUNCTION("","getHelloWorld") { DEBUG(#,"getHelloWorld") ..... ..... ..... hint "hello world" <<--- without ; }; and it alerts me that missing ; at line 4 in file getHelloWorld. Thank you for your very appreciated help, if you have other idea to improve the code, don't hesitate :) 2 Share this post Link to post Share on other sites