ID:2068501
 
Code:
#define GLOBTD(vname,vtype,def) /var/##vtype/##vname = def;
GLOBTD(demo,turf/floor,new)
/client/verb/demonstrate()
world << demo


Problem description:
I'm doing some wonky things with defines(don't ask, is necessary with this project)
As soon as I use the define, the entire project starts to freak out and it doesn't even set the var right, it causes a "bad output" error.
That's the incorrect syntax for a #define declaration. The right way is,
#define GLOBTD(vname, vtype, def) /var/vtype/vname = def;
I think ## should be substituting directly just fine, though; it's actually meant for cases where you want to sub into a var name or such. To me the syntax actually looks good; it's possible this could be a bug.

[edit]
Okay, good news: This isn't a bug. The problem is that you're creating a turf like this:

var/turf/floor/demo = new

Turfs cannot be created this way. They always need a location, and new/turf() only works when you supply an existing turf as that location. Basically, your demo var is not holding a turf or null, but something else; you can output its \ref to see.

If the var type is an obj, the bad output issue goes away.
In response to Lummox JR
Lummox JR wrote:
I think ## should be substituting directly just fine, though; it's actually meant for cases where you want to sub into a var name or such.

I was unaware such syntax was even a thing in DM. I assumed he was pulling the syntax from another language.
Yeah, it's not documented, but it works.

#x makes x into "x"
##x inserts x directly into the replacement expression
n###x does ##x, n times

I haven't done any testing of those myself; that's just from exploring the preprocessor code.