You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Jim Jagielski <ji...@devsys.jaguNET.com> on 1999/11/30 00:40:23 UTC

Re: cvs commit: apache-2.0/src/os/win32 os.h

manoj@hyperreal.org wrote:
> 
>   Log:
>   The first part of the big autoconf patch. This replaces a bunch of
>   NEED_* macros with HAVE_* macros to be more consistent with autoconf.
>   
>    
>   -#ifdef NEED_STRDUP
>   +#ifndef HAVE_STRDUP
>    char *strdup(const char *str)
>    {
>        char *sdup;

Is this quite right? Isn't the "right" way to have

	#if HAVE_STRDUP

This means, of course, that we are consistant with having
such variables defined as either 0 or 1, instead of simply
#define'ing and #undef'ing them, but I think the former
is the "recommended" way... I may be wrong (most likely
I am :) ).
-- 
===========================================================================
   Jim Jagielski   [|]   jim@jaguNET.com   [|]   http://www.jaguNET.com/
                "Are you suggesting coconuts migrate??"

Re: cvs commit: apache-2.0/src/os/win32 os.h

Posted by Greg Stein <gs...@lyra.org>.
+1 on using the #define/#undef paradigm (and use #ifdef). Keep it pure
autoheader-style...

Cheers,
-g

On Mon, 29 Nov 1999, Manoj Kasichainula wrote:
> On Mon, Nov 29, 1999 at 07:46:28PM -0500, Jim Jagielski wrote:
> > Manoj Kasichainula wrote:
> > > What happens when you "#if HAVE_STRDUP" and HAVE_STRDUP is not
> > > defined? If the compiler blows up, then we should leave things the way
> > > they are.
> > 
> > Agreed, that's why I said that we need to make sure that for
> > every preprocessor variable we use, we would need to make sure
> > it's 0 or 1. Of course, doing this forces us to make sure that's
> > that case or else the compiler/preprocessor will barf (good for
> > finding typos).
> 
> This is the problem. :) It's really really helpful to use autoheader
> to generate ap_config_auto.h.in. And autoheader uses #define/#undef.
> 
> It's not a big deal anyway. If someone pipes up and says that
> compilers can stand it, it's easy to change later if we want.
> 
> -- 
> Manoj Kasichainula - manojk at io dot com - http://www.io.com/~manojk/
> 

-- 
Greg Stein, http://www.lyra.org/


Re: cvs commit: apache-2.0/src/os/win32 os.h

Posted by Manoj Kasichainula <ma...@io.com>.
On Mon, Nov 29, 1999 at 07:46:28PM -0500, Jim Jagielski wrote:
> Manoj Kasichainula wrote:
> > What happens when you "#if HAVE_STRDUP" and HAVE_STRDUP is not
> > defined? If the compiler blows up, then we should leave things the way
> > they are.
> 
> Agreed, that's why I said that we need to make sure that for
> every preprocessor variable we use, we would need to make sure
> it's 0 or 1. Of course, doing this forces us to make sure that's
> that case or else the compiler/preprocessor will barf (good for
> finding typos).

This is the problem. :) It's really really helpful to use autoheader
to generate ap_config_auto.h.in. And autoheader uses #define/#undef.

It's not a big deal anyway. If someone pipes up and says that
compilers can stand it, it's easy to change later if we want.

-- 
Manoj Kasichainula - manojk at io dot com - http://www.io.com/~manojk/

Re: cvs commit: apache-2.0/src/os/win32 os.h

Posted by Manoj Kasichainula <ma...@io.com>.
On Mon, Nov 29, 1999 at 06:40:23PM -0500, Jim Jagielski wrote:
> Is this quite right? Isn't the "right" way to have
> 
> 	#if HAVE_STRDUP
> 
> This means, of course, that we are consistant with having
> such variables defined as either 0 or 1, instead of simply
> #define'ing and #undef'ing them, but I think the former
> is the "recommended" way... I may be wrong (most likely
> I am :) ).

If you put "#define HAVE_UNISTD_H 0" in ap_config_auto.h, configure
will change it to "#define HAVE_UNISTD_H 1". It will also change
#undefs to the same string, so autoconf can deal with both systems
just fine.

Autoheader, though, generates macros of the "#undef" type, so I went
with that system. See acconfig.h.in and the various config.h.stub
files.

What happens when you "#if HAVE_STRDUP" and HAVE_STRDUP is not
defined? If the compiler blows up, then we should leave things the way
they are.

If the compiler is lax, and #if is treated as 0, then it's probably
somewhat more defensive to use #if instead of #ifdef so that we deal
with "#define HAVE_BLAH 0" properly. But, this really shouldn't happen
if we all pay attention. :)

I believe that gcc is lax, but can we depend on this for all ANSI C
compilers?

-- 
Manoj Kasichainula - manojk at io dot com - http://www.io.com/~manojk/