On May 4, 2012, at 9:13 PM, Tony Cook wrote:

> C++ has allowed mixed statements and declarations since its creation,
> how about:
> 
> #ifdef __cplusplus
> #define dNOOP
> #else
> #define dNOOP extern int Perl___notused(void)
> #endif

Thanks for the suggestion.  That might work, but might also fall afoul of the 
naked semicolon problem noted in the comment in perl.h:

#define NOOP /*EMPTY*/(void)0
/* cea2e8a9dd23747f accidentally lost the comment originally from the first
   check in of thread.h, explaining why we need dNOOP at all:  */
/* Rats: if dTHR is just blank then the subsequent ";" throws an error */
/* Declaring a *function*, instead of a variable, ensures that we don't rely
   on being able to suppress "unused" warnings.  */
#define dNOOP extern int Perl___notused(void)

But maybe that error would only happen with C and not C++?

The definition of dNOOP is an extremely well-trodden line of code with lots of 
changes demonstrating that anything that fixes a problem with it is highly 
likely to introduce one or more other problems.  

I don't actually understand why we need a dNOOP that's distinct from NOOP, 
i.e., why we can't just do:

#define dNOOP (void)0

or perhaps:

#ifdef __cplusplus
#define dNOOP (void)0
#else
#define dNOOP extern int Perl___notused(void)
#endif


________________________________________
Craig A. Berry
mailto:craigbe...@mac.com

"... getting out of a sonnet is much more
 difficult than getting in."
                 Brad Leithauser

Reply via email to