This is the mail archive of the
mailing list for the GCC project.
Re: alloca and c++
- From: Devang Patel <dpatel at apple dot com>
- To: Gabriel Dos Reis <gdr at codesourcery dot com>
- Cc: Devang Patel <dpatel at apple dot com>, gcc at gcc dot gnu dot org
- Date: Fri, 1 Feb 2002 12:25:12 -0800
- Subject: Re: alloca and c++
On Friday, February 1, 2002, at 12:12 PM, Gabriel Dos Reis wrote:
> Devang Patel <firstname.lastname@example.org> writes:
> | Hello,
> | Following gives me undefined (not undeclared) 'alloca' error in C++.
> | Is it expected ?
> Alloca() is not a standard function. And on systems I've seen it used,
> the appropriate header was included.
Yes. On the darwin system, stdlib.h provides the alloca. But the results
I tried again.
[bardoli:/Volumes/Sandbox/Testing/gcc3]$ cat test_alloca.cc
char *s = (char *) alloca (10);
[bardoli:/Volumes/Sandbox/Testing/gcc3]$ /usr/gcc3/bin/g++ test_alloca.cc
ld: Undefined symbols:
I am *not* getting, undeclared alloca error. Which I do get
if I do not include <stdlib.h> or do not provide alloca() declaration.
> | Or am I suppose to use __builtin_alloca() to get gcc-built-in
> | in C++ source ?
So, my question is :
Even though I include stdilib.h,
I can not use alloca() in c++ and I must use __builtin_alloca().
Is it True ?
> And declaring standard functions "by hand" is evil. Use appropriate
> header for that.
I know. I did it to simplify the test case.
(And to probably to avoid answers that my stdlib.h might not have