I get the same problem. Seems to occur in the general case:
// 'bar' is some type #define foo bar
// as part of definition... ...foo/baz
The error appears to be the same message produced as this case:
// 'list': undefined var // 'test_list': undefined var var/list /test_list
My guess is that when the macro is inserted an extra space is inserted at the end.
Not sure what workarounds are possible. This works:
#define Vector3 list/position
mob/New(Vector3) x = position[1] // etc.
But has obvious drawbacks.
You can use the token-pasting operator:
#define Vector3(x) list/##x
mob/New(Vector3(position)) world << position
Doesn't look quite right, but better than nothing.
EDIT: I've submitted a bug report http://www.byond.com/members/ DreamMakers?command=add_tracker_issue&tracker=1 . This might be intended behaviour of #define - I suspect they're using a C++ preprocessor (because token-pasting and stringification operators work), and c/c++ are significantly more lax on where whitespace can occur than DM.
Jp wrote: > I get the same problem. Seems to occur in the general case: > > <dm> > > // 'bar' is some type > #define foo bar > > // as part of definition... > ...foo/baz >
The error appears to be the same message produced as this case:
> // 'list': undefined var > // 'test_list': undefined var > var/list /test_list >
My guess is that when the macro is inserted an extra space is inserted at the end.
Not sure what workarounds are possible. This works:
> #define Vector3 list/position > > mob/New(Vector3) > x = position[1] // etc. >
But has obvious drawbacks.
You can use the token-pasting operator:
> #define Vector3(x) list/##x > > mob/New(Vector3(position)) > world << position >
Doesn't look quite right, but better than nothing.
Ok for one fixed. You had foo/baz instead of foo/bar..
Ok for one fixed. You had foo/baz instead of foo/bar..
> > // 'bar' is some type > #define foo bar > > // as part of definition... > ...foo/bar >
No space should be included...
> var/list/test_list >
You're not following - 'baz' was intentional in the last example, as a stand-in for the variable name. Your 'fix' is the equivalent of this:
var/list/list
which is clearly wrong.
I'm aware no space should be included. My point is that when a macro is expanded a space appears to be appended in the preprocessed code, causing these issues. My guess is this is because Dream Maker has likely repurposed a C++ preprocessor, and C/C++ are distinctly friendlier to having random whitespace in statements than DM is.
My example with the space in it is there because it triggers similar error messages to the case with the macro.
If you don't know what we're talking about, read the reference page on the #define directive.