pawn-lang / compiler

Pawn compiler for SA-MP with bug fixes and new features - runs on Windows, Linux, macOS
Other
306 stars 72 forks source link

Can't conditionally compile comments #674

Closed Y-Less closed 2 years ago

Y-Less commented 3 years ago

Issue description:

Comments seem to ignore #if. While this seems like it shouldn't matter, it does when compiling documentation (pawndoc) comments with -r.

Minimal complete verifiable example (MCVE):

#if 0
/** hello */
#endif
/** world */

main()
{
}

That will give the following output when compiled with -r:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet href="file:///C|/Users/Alex/Documents/SA-MP/pawno/xml/pawndoc.xsl" type="text/xsl"?>
<doc source="C:\Users\Alex\Documents\SA-MP\gamemodes\pawndoc-bug.pwn">
    <assembly>
        <name>pawndoc-bug.pwn</name>
    </assembly>

    <!-- general -->
    <general>
        hello 
    </general>

    <members>

        <!-- enumerations -->

        <!-- constants -->

        <!-- variables -->
        <member name="F:__date">
        </member>
        <member name="F:__file">
        </member>
        <member name="F:__time">
        </member>

        <!-- functions -->
        <member name="M:main" syntax="main()">
            <attribute name="entry"/>
            <stacksize value="1"/>
            world 
        </member>

    </members>
</doc>

Obviously the hello is present, when it shouldn't be.

Workspace Information:

Windows 3.10.11 (HEAD)

Y-Less commented 3 years ago

I found a bad work-around:

#if 0
/** hello */
#else
static stock IGNORE_THIS_DOCUMENTATION() {}
#endif
/** world */

main()
{
}

The hello comment still ends up in the XML file, but it is now attached to a function and can be moved around.

Y-Less commented 3 years ago
#if 0
/** hello */
#else
const IGNORE_THIS_DOCUMENTATION = 0;
#endif
/** world */

main()
{
}

That completely removes it.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity.

Y-Less commented 2 years ago

Duplicate of #186