[niemeyer@conectiva.com: Re: [Python-Dev] Python's footprint]

jepler@inetnebr.com jepler@inetnebr.com
Mon, 14 Jan 2002 07:41:57 -0600


The following is the solution that comes to mind for me.  My other idea was
creating a static char* or a static function with the char* inside it, in
the hopes it would be discarded as unused, but gcc doesn't seem to do that.

Seems to me that compared to this, rewriting those docstrings that are
victim of preprocessor definitions already is certainly better for
readability of the docstrings in the source code...

Jeff Epler
jepler@inetnebr.com
On Mon, Jan 14, 2002 at 09:30:53AM -0200, Gustavo Niemeyer wrote:
> I'm looking for some way to "discard" the string using a macro. Let me
> explain with code:
> 
> [...]
> #define Py_DOCSTR(name, str) static char *name = str
> #ifdef WITH_DOC_STRINGS
> #define Py_DOCSTR_START(name) Py_DOCSTR(name,)
> #define Py_DOCSTR_END ;
  #define Py_DOCSTR_PART(s) s
> #else
> #define Py_DOCSTR_START(name) Py_DOCSTR(name, ""); /* Also discards what
>                                                       follows somehow */
> #define Py_DOCSTR_END /* Stop discarding */
  #define Py_DOCSTR_PART(s) /* (nothing) */
> #endif
> [...]
> 
> 
> This would make it possible to do something like this:
> 
> Py_DOCSTR(simple_doc, "This is a simple doc string.");
> 
> ...and also...
> 
> Py_DOCSTR_START(complex_doc)
  Py_DOCSTR_PART(              "This is a complex doc string")
> #ifndef MS_WIN16
  Py_DOCSTR_PART(              "like the one in sysmodule.c")
> #endif
  Py_DOCSTR_PART(              "Something else")
> Py_DOCSTR_END