Skip to content

Commit c4da28b

Browse files
committed
Change names in OpTYPE_set() to avoid possible collisions
This uses the PERL_UNIQUE_NAME() macro created in the previous commit to get unique names for variables in macro expansions. Suppose you have #define foo STMT_START { ... } STMT_END block, and have a variable 'bar' declared in it. By first saying #define bar PERL_UNIQUE_NAME(bar) 'bar' will be replaced in the expansion of 'foo' by a unique value. It is your responsibility to not have two 'bar' symbols in the same program. But if you forget, you will be warned by the compiler that 'bar' is redefined, so you can fix it .
1 parent 86d15ec commit c4da28b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

op.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,14 @@ typedef PERL_BITFIELD16 Optype;
6464
U8 op_private;
6565
#endif
6666

67+
#define o1_ PERL_UNIQUE_NAME(o)
68+
#define type1_ PERL_UNIQUE_NAME(type)
6769
#define OpTYPE_set(o,type) \
6870
STMT_START { \
69-
OP *o_ = (OP *)o; \
70-
OPCODE type_ = type; \
71-
o_->op_type = type_; \
72-
o_->op_ppaddr = PL_ppaddr[type_]; \
71+
OP *o1_ = (OP *)o; \
72+
OPCODE type1_ = type; \
73+
o1_->op_type = type1_; \
74+
o1_->op_ppaddr = PL_ppaddr[type1_]; \
7375
} STMT_END
7476

7577
/* If op_type:9 is changed to :10, also change cx_pusheval()

0 commit comments

Comments
 (0)