Page MenuHomeFeedback Tracker

[Function Preprocessor Bug] Line numbers not correct in functions with #include
Closed, ResolvedPublic

Description

The function preprocessor is broken. The line numbers are incorrect.

It's because no #line directives are added before the #include (#line 1 "PATH\define.hpp) and after the #include (#line N "PATH\fn_someFnc.sqf")

See the steps to reproduce and additional details.

preprocessorFileLineNumbers works fine.

Details

Severity
Minor
Resolution
Open
Reproducibility
N/A
Operating System
Windows 7
Category
Engine
Steps To Reproduce

Create a function in description.ext. Put this EXACT code in it (it contains errors but it's for testing):

#include "defines.hpp"
"line2";
"line3";
"line4";
"This should be line 5" BUT ITS LINE10

contents of defines.hpp (5 lines):

"incl line 1";
"incl line 2";
"incl line 3";
"incl line 4";
"incl line 5";

This is how the function is preprocessed by CfgFunctions (use copyToClipboard str TEST_fnc_TEST):

{
	private _fnc_scriptNameParent = if (isNil '_fnc_scriptName') then {'TEST_fnc_TEST'} else {_fnc_scriptName};
	private _fnc_scriptName = 'TEST_fnc_TEST';
	scriptName _fnc_scriptName;

#line 1 "TEST\fn_TEST.sqf [TEST_fnc_TEST]"
"incl line 1";
"incl line 2";
"incl line 3";
"incl line 4";
"incl line 5";
"line2";
"line3";
"line4";
"This should be line 5" BUT ITS LINE10}
Additional Information

This is how it should be (you can validate this if you use preprocessorFileLineNumbers instead of functions):
Notice that there are now 2 #line directives. One before the #include (with file name set to that of the header file), and one after it (with file name set to the source file)

{
	private _fnc_scriptNameParent = if (isNil '_fnc_scriptName') then {'TEST_fnc_TEST'} else {_fnc_scriptName};
	private _fnc_scriptName = 'TEST_fnc_TEST';
	scriptName _fnc_scriptName;

#line 1 "TEST\defines.hpp"
"included line 1";
"included line 2";
"included line 3";
"included line 4";
"included line 5";
#line 1 "TEST\fn_TEST.sqf [TEST_fnc_TEST]"
"line2";
"line3";
"line4";
"This should be line 5" BUT ITS LINE10}

Event Timeline

Leopard20 created this task.Nov 4 2020, 7:15 PM
Leopard20 updated the task description. (Show Details)
Leopard20 updated the task description. (Show Details)
Leopard20 edited Additional Information. (Show Details)
Leopard20 edited Additional Information. (Show Details)Nov 4 2020, 7:18 PM
Leopard20 updated the task description. (Show Details)Nov 4 2020, 7:33 PM
Leopard20 changed Severity from Major to Minor.Feb 4 2021, 2:24 PM
Leopard20 updated the task description. (Show Details)Feb 4 2021, 2:31 PM
Leopard20 updated the task description. (Show Details)Feb 4 2021, 2:40 PM
Leopard20 edited Steps To Reproduce. (Show Details)
Leopard20 edited Additional Information. (Show Details)
Leopard20 edited Steps To Reproduce. (Show Details)
Leopard20 edited Additional Information. (Show Details)Feb 4 2021, 2:43 PM
Leopard20 edited Steps To Reproduce. (Show Details)Feb 4 2021, 2:52 PM
Leopard20 edited Additional Information. (Show Details)
dedmen closed this task as Resolved.Feb 4 2021, 2:58 PM
dedmen claimed this task.
dedmen added a subscriber: dedmen.

Not a preprocessor bug.
CfgFunction uses preprocessFile, that is supposed to not have line numbers.
Everything is working correctly here.

CfgFunctions should be changed to use preprocessFileLineNumbers yes, and it will be. But nothing is wrong with the preprocessor.

R3vo added a subscriber: R3vo.May 12 2021, 10:44 PM
R3vo removed a subscriber: R3vo.