alliedmodders / sourcepawn

A small, statically typed scripting language.
Other
369 stars 63 forks source link

Broken (?) CLI define definitions for simple comparation #856

Closed CrazyHackGUT closed 1 year ago

CrazyHackGUT commented 2 years ago

Fix for issue #561 is broke my CI: i use CLI definition for building plugin also in debug mode. Compiler runs with parameter __CI_DEBUG=1, in sources i have this:

#define DEBUG 0 
// ...
#if defined __CI_DEBUG
    #undef DEBUG
    #define DEBUG __CI_DEBUG
#endif 

In places, where i have some debug logs, i use construction like this:

#if DEBUG
    LogToFile(g_szDebug_Admin, "For admin %s created a new entry in admincache (%x): group \"%s\", permissions %x, immunity %d", szName, iAdminId, szGroup, iPermissions, iImmunity);
#endif

Now compiler fails with error mentioned in fix:

materialadmin/menu.sp(142) : error 230: symbol "__MADEBUG" is not a preprocessor symbol; this behavior is undefined and will be removed in the future
materialadmin/menu.sp(206) : error 230: symbol "__MADEBUG" is not a preprocessor symbol; this behavior is undefined and will be removed in the future
materialadmin/menu.sp(237) : error 230: symbol "__MADEBUG" is not a preprocessor symbol; this behavior is undefined and will be removed in the future
materialadmin/menu.sp(353) : error 230: symbol "__MADEBUG" is not a preprocessor symbol; this behavior is undefined and will be removed in the future
materialadmin/menu.sp(623) : error 230: symbol "__MADEBUG" is not a preprocessor symbol; this behavior is undefined and will be removed in the future
materialadmin/menu.sp(640) : error 230: symbol "__MADEBUG" is not a preprocessor symbol; this behavior is undefined and will be removed in the future
materialadmin/menu.sp(661) : error 230: symbol "__MADEBUG" is not a preprocessor symbol; this behavior is undefined and will be removed in the future
materialadmin/menu.sp(671) : error 230: symbol "__MADEBUG" is not a preprocessor symbol; this behavior is undefined and will be removed in the future
materialadmin/admin.sp(48) : error 230: symbol "__MADEBUG" is not a preprocessor symbol; this behavior is undefined and will be removed in the future
materialadmin/admin.sp(60) : error 230: symbol "__MADEBUG" is not a preprocessor symbol; this behavior is undefined and will be removed in the future
materialadmin/admin.sp(72) : error 230: symbol "__MADEBUG" is not a preprocessor symbol; this behavior is undefined and will be removed in the future
materialadmin/admin.sp(85) : error 230: symbol "__MADEBUG" is not a preprocessor symbol; this behavior is undefined and will be removed in the future
materialadmin/admin.sp(126) : error 230: symbol "__MADEBUG" is not a preprocessor symbol; this behavior is undefined and will be removed in the future
materialadmin/admin.sp(137) : error 230: symbol "__MADEBUG" is not a preprocessor symbol; this behavior is undefined and will be removed in the future
materialadmin/admin.sp(225) : error 230: symbol "__MADEBUG" is not a preprocessor symbol; this behavior is undefined and will be removed in the future
materialadmin/admin.sp(245) : error 230: symbol "__MADEBUG" is not a preprocessor symbol; this behavior is undefined and will be removed in the future
materialadmin/admin.sp(255) : error 230: symbol "__MADEBUG" is not a preprocessor symbol; this behavior is undefined and will be removed in the future
materialadmin/admin.sp(283) : error 230: symbol "__MADEBUG" is not a preprocessor symbol; this behavior is undefined and will be removed in the future
materialadmin/admin.sp(362) : error 230: symbol "__MADEBUG" is not a preprocessor symbol; this behavior is undefined and will be removed in the future
materialadmin/admin.sp(398) : error 230: symbol "__MADEBUG" is not a preprocessor symbol; this behavior is undefined and will be removed in the future
materialadmin/admin.sp(452) : error 230: symbol "__MADEBUG" is not a preprocessor symbol; this behavior is undefined and will be removed in the future
materialadmin/config.sp(218) : error 230: symbol "__MADEBUG" is not a preprocessor symbol; this behavior is undefined and will be removed in the future
materialadmin/config.sp(238) : error 230: symbol "__MADEBUG" is not a preprocessor symbol; this behavior is undefined and will be removed in the future
materialadmin/config.sp(258) : error 230: symbol "__MADEBUG" is not a preprocessor symbol; this behavior is undefined and will be removed in the future
materialadmin/config.sp(265) : error 230: symbol "__MADEBUG" is not a preprocessor symbol; this behavior is undefined and will be removed in the future
materialadmin/config.sp(274) : error 230: symbol "__MADEBUG" is not a preprocessor symbol; this behavior is undefined and will be removed in the future

Minimal reproduce case:

#include <sourcemod>

#define DUMMY   0
#if defined __CLIDEFINE
    #undef DUMMY
    #define DUMMY __CLIDEFINE
#endif

public void OnPluginStart()
{
    #if DUMMY
        PrintToServer("Dummy!");
    #endif
}

compiler run

dvander commented 1 year ago

Is __CLIDEFINE defined anywhere?

CrazyHackGUT commented 1 year ago

No, it defined only in CLI params for compiler.

Wend4r commented 1 year ago

image

I have same problem on

SourcePawn Compiler 1.11.0.6860

dvander commented 1 year ago

Can't repro:

dvander@DESKTOP-675KUFV:~/alliedmodders/sourcepawn$ ./spcomp test.sp -itests/sourcemod/include __CLIDEFINE=1
SourcePawn Compiler 1.12
Copyright (c) 1997-2006 ITB CompuPhase
Copyright (c) 2004-2021 AlliedModders LLC

Code size:         3508 bytes
Data size:         2284 bytes
Stack/heap size:      16452 bytes
Total requirements:   22244 bytes