Page MenuHomeFeedback Tracker

"__has_include" PreProcessor command errors out when placed after an #else in description.ext
New, NormalPublic

Description

Trying to use the __has_include preprocessor command immediately after an #if, #else, #endif block in the same file results in a "Preprocessor Error - Invalid File Name(empty filename)" erorr.

This doesn't seem to occur when the #if block immediately above the __has_include command does not have an #else entry. It doesn't seem to matter if any #if blocks earlier in the file have an #else entry, as long as the block immediately before the __has_include does not.

Here are some examples from a description.ext file (in this case, searching for a file from the ACE3 mod):
This code block seems to work without issue.

#define TESTDEFINE 1

#ifdef TESTDEFINE
    first_mission_value = 1;
#else
    first_mission_value = 0;
#endif

#ifdef TESTDEFINE
    second_mission_value = 1;
#endif

#if __has_include("\z\ace\addons\main\script_component.hpp")
    ace3_value = 1;
#endif

This code block results in a "Preprocessor Error - Invalid File Name(empty filename)" error

#define TESTDEFINE 1

#ifdef TESTDEFINE
    second_mission_value = 1;
#endif

#ifdef TESTDEFINE
    first_mission_value = 1;
#else
    first_mission_value = 0;
#endif

#if __has_include("\z\ace\addons\main\script_component.hpp")
    ace3_value = 1;
#endif

Details

Severity
None
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Operating System Version
19043.1151
Category
Config
Steps To Reproduce
  1. Create a new mission in the 3DEN editor.
  2. Add a description.ext file to the mission, with one of the above blocks of code.
  3. See that the first block of code will work correctly, where the second block of code will throw an error upon saving/loading the mission file.
Additional Information

Tested on the current stable Arma 3 build (2.04.147719), as well as the current dev branch (147890)

Event Timeline

BIS_fnc_KK assigned this task to dedmen.Aug 10 2021, 9:37 AM
dedmen added a comment.EditedAug 10 2021, 4:25 PM

#if is broken, not __has_include.
#if after a #else is bad.

Or alternatively, #else is broken for both ifdef and if