Wire: E2: Found nested #ifdef/#ifndef pre-processor directive error

Created on 16 Jun 2016  路  9Comments  路  Source: wiremod/wire

@TomyLobo If I recall correctly, you have made those pre-processor directives?
If so, can you make them "nestable"?
I have just noticed my "Deprecated" E2 (utility) library doesn't validate/run because of this (see this part).
Also I have noticed I can't test multiple functions as in:

#ifdef function1() & !function2()
# Stuff...
#endif

-or-

#ifdef function1()
#ifndef function2()
# Stuff...
#endif
#endif
E2 Enhancement Suggestion

Most helpful comment

Hmm, according to PiL, it's much simpler than that:
https://www.lua.org/pil/19.2.html
"With those two functions, it is straightforward to implement stacks[...]. We can initialize such structures as a = {}. A push operation is equivalent to table.insert(a, x); a pop operation is equivalent to table.remove(a)."

> a={1,2,3,4,5}
> function p(a) for x in ipairs(a) do print(x) end end
> p(a)
1
2
3
4
5
> table.insert(a,6)
> p(a)
1
2
3
4
5
6
> return table.remove(a)
6
> return table.remove(a)
5
> return table.remove(a)
4
> return table.remove(a)
3
> return table.remove(a)
2
> return table.remove(a)
1
> return table.remove(a)
>

So yeah, you can just use table.insert/remove instead of garry's stack

All 9 comments

I remember that I tried to add these features, but failed. I don't think it's easily feasible.

https://github.com/wiremod/wire/blob/master/lua/entities/gmod_wire_expression2/base/preprocessor.lua#L368

you'd need to add kind of a stack there
i think there's a stack class somewhere in wiremod that you can use

I haven't seen Stack that comes with Wire, yet..
Anyways, there is one that comes builtin.
I had one in pure Lua (just can't remember where I have saved it..). But, I guess builtin Stack should be good to go.

I had one in pure Lua (just can't remember where I have saved it..). But, I guess builtin Stack should be good to go.

It is in pure Lua, source

yeah you could use that i guess...
@Divran or is that a bad idea due to people trying to use E2 without gmod?

E2 can't be used without gmod anyway, so that doesn't matter. I'd still not use garry's (probably bad) class though. I'd probably just use a regular lua table as a stack.

I'd still not use garry's (probably bad) class though. I'd probably just use a regular lua table as a stack.

Well I mean, it's not bad in implementation terms, but the methods are pretty much just glorified table operations.

I'd still prefer seeing "local bar = foo.Pop()" to "local bar = foo[#foo] foo[#foo] = nil" everywhere.

Hmm, according to PiL, it's much simpler than that:
https://www.lua.org/pil/19.2.html
"With those two functions, it is straightforward to implement stacks[...]. We can initialize such structures as a = {}. A push operation is equivalent to table.insert(a, x); a pop operation is equivalent to table.remove(a)."

> a={1,2,3,4,5}
> function p(a) for x in ipairs(a) do print(x) end end
> p(a)
1
2
3
4
5
> table.insert(a,6)
> p(a)
1
2
3
4
5
6
> return table.remove(a)
6
> return table.remove(a)
5
> return table.remove(a)
4
> return table.remove(a)
3
> return table.remove(a)
2
> return table.remove(a)
1
> return table.remove(a)
>

So yeah, you can just use table.insert/remove instead of garry's stack

Was this page helpful?
0 / 5 - 0 ratings

Related issues

CSGKCJDBCPQ2K8 picture CSGKCJDBCPQ2K8  路  8Comments

CaptainPRICE picture CaptainPRICE  路  8Comments

nokoto6 picture nokoto6  路  4Comments

CaptainPRICE picture CaptainPRICE  路  9Comments

CaptainPRICE picture CaptainPRICE  路  3Comments