ID:2366472
 
BYOND Version:512.1414
Operating System:Linux
Web Browser:
Applies to:DM Language
Status: Open

Issue hasn't been assigned a status value.
Sorry if this has been reported. The forum search still doesn't work.

Descriptive Problem Summary:
Bare preprocessor directives do not work within complex macros (ones with parameters, which may have a proper name that I just don't know) because the # that they begin with is interpreted as a command to turn them into text. They work just fine in simple macros, and will even work in complex macros if "wrapped" in simple macros. This doesn't always work, though, as explained below.
Oh, and attempting to escape the # simply escapes the following quotation mark inserted by the preprocessor instead.

Numbered Steps to Reproduce Problem:
1. Stick any of the below snippets into a proc.
2. Attempt to compile.

Code Snippet (if applicable) to Reproduce Problem:
1. (Works)
#define TEST #error
TEST help


2. (Does not work)
#define TEST(a) #error a
TEST(help)


3. (Works)
#define TEST2 #error
#define TEST(a) TEST2 a
TEST(help)


4. (I really just did this one to see what would happen)
#define _error #error
#define TEST(a) _error #error
TEST(1)


Expected Results:
1. error: #error help
2. error: #error help
3. error: #error help
4. No idea

Actual Results:
1. error: #error help
2. error: expected expression
3. error: #error help
4. error: #error "error"

Does the problem occur:
Every time? Or how often?
Every time.
In other games?
This was found in a test environment, not a game at all.
In other user accounts?
No login involved.
On other computers?
Not tested, but there's no reason to expect it wouldn't happen.

When does the problem NOT occur?
In simple macros without parameters.


Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)
I doubt it, but haven't checked.

Workarounds:
Wrap all preprocessor directives that need to be used in complex macros with simple macros. However, this will not work with #endif because the wrapper macro won't be processed while the compiler is skipping code, so it will hit the end of the file and fail to compile. There are likely similar cases in which it also will not work.