As suggested by Sarathy, add -DPERL_HIDE_SHORT_NAMES option
authorJarkko Hietaniemi <jhi@iki.fi>
Sun, 16 Feb 2003 09:47:02 +0000 (09:47 +0000)
committerJarkko Hietaniemi <jhi@iki.fi>
Sun, 16 Feb 2003 09:47:02 +0000 (09:47 +0000)
which will disable the short forms of the Perl_ API, good for
embedding stuff.  (Kind of like the old NO_EMBED, but better.)

p4raw-id: //depot/perl@18718

embed.h
embed.pl
pod/perlembed.pod

diff --git a/embed.h b/embed.h
index b8cc87b..e369c33 100644 (file)
--- a/embed.h
+++ b/embed.h
 
 /* (Doing namespace management portably in C is really gross.) */
 
-/* NO_EMBED is no longer supported. i.e. EMBED is always active. */
+/* NO_EMBED is no longer supported. i.e. EMBED is always active--
+ * but you can define PERL_HIDE_SHORT_NAMES to achieve the same. */
+
+#ifndef PERL_HIDE_SHORT_NAMES
 
 /* Hide global symbols */
 
 
 #endif /* PERL_IMPLICIT_CONTEXT */
 
+#endif /* #ifndef PERL_HIDE_SHORT_NAMES */
+
 
 /* Compatibility stubs.  Compile extensions with -DPERL_NOCOMPAT to
    disable them.
    an extra argument but grab the context pointer using the macro
    dTHX.
  */
-#if defined(PERL_IMPLICIT_CONTEXT)
+#if defined(PERL_IMPLICIT_CONTEXT) && !defined(PERL_HIDE_SHORT_NAMES)
 #  define croak                                Perl_croak_nocontext
 #  define deb                          Perl_deb_nocontext
 #  define die                          Perl_die_nocontext
index a2a509e..5fc18a7 100755 (executable)
--- a/embed.pl
+++ b/embed.pl
@@ -316,7 +316,10 @@ print EM do_not_edit ("embed.h"), <<'END';
 
 /* (Doing namespace management portably in C is really gross.) */
 
-/* NO_EMBED is no longer supported. i.e. EMBED is always active. */
+/* NO_EMBED is no longer supported. i.e. EMBED is always active--
+ * but you can define PERL_HIDE_SHORT_NAMES to achieve the same. */
+
+#ifndef PERL_HIDE_SHORT_NAMES
 
 /* Hide global symbols */
 
@@ -428,6 +431,8 @@ print EM <<'END';
 
 #endif /* PERL_IMPLICIT_CONTEXT */
 
+#endif /* #ifndef PERL_HIDE_SHORT_NAMES */
+
 END
 
 print EM <<'END';
@@ -472,7 +477,7 @@ print EM <<'END';
    an extra argument but grab the context pointer using the macro
    dTHX.
  */
-#if defined(PERL_IMPLICIT_CONTEXT)
+#if defined(PERL_IMPLICIT_CONTEXT) && !defined(PERL_HIDE_SHORT_NAMES)
 #  define croak                                Perl_croak_nocontext
 #  define deb                          Perl_deb_nocontext
 #  define die                          Perl_die_nocontext
index b9aae2d..24385dd 100644 (file)
@@ -1038,6 +1038,24 @@ also need this path so it knows where to find Perl include files.
 This path can be added via the Tools -> Options -> Directories menu.
 Finally, select Build -> Build interp.exe and you're ready to go.
 
+=head1 Hiding Perl_
+
+If you completely hide the short forms forms of the Perl public API,
+add -DPERL_HIDE_SHORT_NAMES to the compilation flags.  This means that
+for example instead of writing
+
+    warn("%d bottles of beer on the wall", bottlecount);
+
+you will have to write the explicit full form
+
+    Perl_warn(aTHX_ "%d bottles of beer on the wall", bottlecount);
+
+(See L<perlguts/Background and PERL_IMPLICIT_CONTEXT for the explanation
+of the C<aTHX_>.> )  Hiding the short forms is very useful for avoiding
+all sorts of nasty (C preprocessor or otherwise) conflicts with other
+software packages (Perl defines about 2400 APIs with these short names,
+take or leave few hundred, so there certainly is room for conflict.)
+
 =head1 MORAL
 
 You can sometimes I<write faster code> in C, but