Skip to content

Commit 26f43ba

Browse files
committed
perl.h - add nice aliases for PERL_DEB() and PERL_DEB2()
This patch adds PERL_IF_DEBUGGING() as an alias for PERL_DEB() and adds PERL_IF_DEBUGGING_ELSE() as an alias for PERL_DEB2(). It also documents them, along with PERL_DEBUG() and DEBUG_r() and friends. Currently I have not switched the existing PERL_DEB() or PERL_DEB2() calls to use the new names. I wanted to get feedback on this first. Thanks to mauke for the name suggestions!
1 parent 8dad829 commit 26f43ba

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

perl.h

+82
Original file line numberDiff line numberDiff line change
@@ -5088,6 +5088,88 @@ Gid_t getegid (void);
50885088
#endif /* DEBUGGING */
50895089

50905090

5091+
/*
5092+
=for apidoc_section $debugging
5093+
=for apidoc mu||PERL_IF_DEBUGGING|code
5094+
5095+
A macro which is executed only when DEBUGGING is enabled.
5096+
Functionally identical to
5097+
5098+
#ifdef DEBUGGING
5099+
code
5100+
#endif
5101+
5102+
but prettier. This macro is useful for declaring variables that are
5103+
only used on DEBUGGING builds. Note that what this macro does is
5104+
determined at compile time, if you want a run time equivalent then
5105+
use C<PERL_DEBUG()> instead.
5106+
5107+
=for apidoc mu||PERL_IF_DEBUGGING_ELSE|code_debugging|code_nondebugging
5108+
5109+
A macro way of expressing different code that should be compiled
5110+
depending on whether DEBUGGING is enabled. Functionally identical
5111+
to
5112+
5113+
#ifdef DEBUGGING
5114+
code_debugging
5115+
#else
5116+
code_nondebugging
5117+
#end
5118+
5119+
but prettier.
5120+
5121+
=for apidoc mu||PERL_DEBUG|code
5122+
A macro way of expressing code that will only be executed when the run
5123+
time internal variable PL_debug is non-zero.
5124+
5125+
=for apidoc mu||DEBUG_A|code
5126+
=for apidoc_item mu||DEBUG_B|code
5127+
=for apidoc_item mu||DEBUG_C|code
5128+
=for apidoc_item mu||DEBUG_c|code
5129+
=for apidoc_item mu||DEBUG_D|code
5130+
=for apidoc_item mu||DEBUG_f|code
5131+
=for apidoc_item mu||DEBUG_i|code
5132+
=for apidoc_item mu||DEBUG_L|code
5133+
=for apidoc_item mu||DEBUG_l|code
5134+
=for apidoc_item mu||DEBUG_Lv|code
5135+
=for apidoc_item mu||DEBUG_m|code
5136+
=for apidoc_item mu||DEBUG_o|code
5137+
=for apidoc_item mu||DEBUG_P|code
5138+
=for apidoc_item mu||DEBUG_p|code
5139+
=for apidoc_item mu||DEBUG_Pv|code
5140+
=for apidoc_item mu||DEBUG_q|code
5141+
=for apidoc_item mu||DEBUG_R|code
5142+
=for apidoc_item mu||DEBUG_r|code
5143+
=for apidoc_item mu||DEBUG_S|code
5144+
=for apidoc_item mu||DEBUG_s|code
5145+
=for apidoc_item mu||DEBUG_T|code
5146+
=for apidoc_item mu||DEBUG_t|code
5147+
=for apidoc_item mu||DEBUG_U|code
5148+
=for apidoc_item mu||DEBUG_u|code
5149+
=for apidoc_item mu||DEBUG_Uv|code
5150+
=for apidoc_item mu||DEBUG_V|code
5151+
=for apidoc_item mu||DEBUG_X|code
5152+
=for apidoc_item mu||DEBUG_x|code
5153+
=for apidoc_item mu||DEBUG_Xv|code
5154+
=for apidoc_item mu||DEBUG_y|code
5155+
=for apidoc_item mu||DEBUG_yv|code
5156+
5157+
These are debugging macros similar to PERL_DEBUG() but which test
5158+
which flags in PL_debug have been set. Each letter corresponds to
5159+
a mode exposed by the -D option to perl. These macros only execute
5160+
when DEBUGGING is enabled, and when the appropriate debug mode
5161+
has been enabled on the command line.
5162+
5163+
See L<perlrun> for details on the meaning of the different
5164+
switches.
5165+
5166+
=cut
5167+
*/
5168+
5169+
#define PERL_IF_DEBUGGING(a) PERL_DEB(a)
5170+
#define PERL_IF_DEBUGGING_ELSE(a,b) PERL_DEB2(a,b)
5171+
5172+
50915173
#define DEBUG_SCOPE(where) \
50925174
DEBUG_l( \
50935175
Perl_deb(aTHX_ "%s scope %ld (savestack=%ld) at %s:%d\n", \

0 commit comments

Comments
 (0)