[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: alloca function use discouraged
From: |
Conrad T. Pino |
Subject: |
RE: alloca function use discouraged |
Date: |
Thu, 15 Apr 2004 12:50:20 -0700 |
Hi Derek,
> From: Conrad T. Pino
>
> > From: Derek Robert Price [mailto:derek@ximbiot.com]
> >
> > It does look like the GNULIB alloca_.h is trying to use the MSC
> > version of _alloca, however:
> >
> > # ifdef _MSC_VER
> > # include <malloc.h>
> > # define alloca _alloca
> > # endif
> >
> > This should mean that the alloca.c module is not required to be
> > compile on Windows, so I don't know why you had to add it to get
> > fnmatch to compile, if you want to look into this and fix it. Perhaps
> > HAVE_ALLOCA_H needs be defined in windows-NT/config.h.in?
>
> I was using "grep" to locate "alloca" references and spotted that too.
>
> I'll look into (1) if "_MSC_VER" is defined and (2) if so which module
> missed the boat.
==============
Your suggestion for HAVE_ALLOCA_H is right on.
------
The short answer to your question:
Defining "HAVE_ALLOCA_H" in "windows-NT/config.h.in" will work.
Consider adding "-D ..." option to .dsp files which mimics behavior
of "configure" script customizing "Makefile".
------
The long answer to your question with evidence:
---
I hacked "alloca_.h" to read:
# ifdef _MSC_VER
# include <malloc.h>
# define alloca _alloca
-> #error Have _MSC_VER
# else
and only 1 error popped out:
vasnprintf.c
.\lib\alloca.h(45) : fatal error C1189: #error : Have _MSC_VER
and the reason is "vasnprintf.c" includes unconditionally"
File lib\vasnprintf.c:
26 # include <config.h>
29 # include <alloca.h>
---
I found 2 other files include conditionally:
File lib\fnmatch.c:
19 # include <config.h>
31 # if defined HAVE_ALLOCA_H || defined _LIBC
32 # include <alloca.h>
File lib\regex.c:
32 # include <config.h>
281 # if HAVE_ALLOCA_H
282 # include <alloca.h>
283 # endif /* HAVE_ALLOCA_H */
and "config.h" includes preceding the "alloca.h" include
conditioned upon "HAVE_ALLOCA_H" in both cases.
---
File "alloca.h" appears to include itself:
File lib\alloca.h:
47 # if HAVE_ALLOCA_H
48 # include <alloca.h>
but this won't affect Windows build because these lines
are nested within other conditional compiles:
# ifdef __GNUC__
[snip]
# else
# ifdef _MSC_VER
[snip]
# else
# if HAVE_ALLOCA_H
# include <alloca.h>
# else
[snip]
# endif
# endif
# endif
that say compiler isn't gcc and isn't MSC/VC.
==============
Here's the issue list:
1. "HAVE_ALLOCA_H" is undefined.
2. "lib/vasnprintf.c" includes unconditionally.
3. "lib/alloca.c" drop from "lib/lib.dsp".
4. "HAVE_ALLOCA_H" can be defined 2 ways.
5. Regenerate & commit .dep/.mak files.
How do you want you/us/I to move forward?
==============
Conrad