pawn-lang/compiler

Can't conditionally compile comments

Closed this issue · 4 comments

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:

  • Compiler version:
  • Command line arguments provided (or sampctl version):
  • Operating System:

Windows 3.10.11 (HEAD)

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.

#if 0
/** hello */
#else
const IGNORE_THIS_DOCUMENTATION = 0;
#endif
/** world */

main()
{
}

That completely removes it.

stale commented

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

Duplicate of #186