sqflint icon indicating copy to clipboard operation
sqflint copied to clipboard

Empty statements and preprocessor control flow

Open AsFoxy opened this issue 7 years ago • 3 comments

Empty statements are treated as errors:

_x =
{
    ;
};

The error was initially caused by this:

#define DEBUG_LOG_TRACE

#define Debug_Log_Impl(mode, message) (diag_log format ['mode: %1', message])

#ifdef DEBUG_LOG_TRACE
	#define Debug_LogTrace(message) Debug_Log_Impl(TRACE,message)
#else
	#define Debug_LogTrace(message)
#endif

Debug_LogTrace("");

_exit =
{
	endMission "END1";
};

It seems that the preprocessor flow control is ignored, and Debug_LogTrace("") is incorrectly expanded as nothing, creating an empty statement. The empty statement in itself is of course perfectly valid.

AsFoxy avatar Jun 02 '17 10:06 AsFoxy

I'm unable to replicate this issue. Is it possible it's caused by some code before this statement?

SkaceKamen avatar Jun 02 '17 10:06 SkaceKamen

It seems the problem is actually empty statements i.e.

_x =
{
    ;
};

The error was initially caused by this:

#define DEBUG_LOG_TRACE

#define Debug_Log_Impl(mode, message) (diag_log format ['mode: %1', message])

#ifdef DEBUG_LOG_TRACE
	#define Debug_LogTrace(message) Debug_Log_Impl(TRACE,message)
#else
	#define Debug_LogTrace(message)
#endif

Debug_LogTrace("");

_exit =
{
	endMission "END1";
};

It seems that the preprocessor flow control is ignored, and Debug_LogTrace("") is incorrectly expanded as nothing, creating an empty statement. The empty statement in itself is of course perfectly valid.

AsFoxy avatar Jun 02 '17 11:06 AsFoxy

Oh, that makes sense. #ifdef is not yet supported, but the parser should accept the empty statement.

Could you move the last comment to the top, so it's clear what the issue is?

SkaceKamen avatar Jun 02 '17 11:06 SkaceKamen