You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Marc Slemko <ma...@znep.com> on 1997/06/05 06:03:10 UTC
other/677: Having trouble with compilation of C++ code using some headers. (fwd)
If I try to compile a simple C++ program (includes httpd.h and has an
empty main()), with g++ I get:
In file included from httpd.h:60,
from test.cc:1:
alloc.h:105: declaration of identifier `pool' as `struct pool * pool'
alloc.h:75: conflicts with other use in class as `struct pool'
In file included from httpd.h:61,
from test.cc:1:
buff.h:92: declaration of identifier `pool' as `struct pool * pool'
alloc.h:75: conflicts with other use in class as `struct pool'
In file included from test.cc:1:
httpd.h:415: declaration of identifier `pool' as `struct pool * pool'
alloc.h:75: conflicts with other use in class as `struct pool'
httpd.h:534: declaration of identifier `pool' as `struct pool * pool'
alloc.h:75: conflicts with other use in class as `struct pool'
This appears to be due to namespace conflict.
typedef struct pool pool;
[...]
typedef struct {
pool *pool;
int elt_size;
int nelts;
int nalloc;
char *elts;
} array_header;
If I change "pool *pool" to "pool *hottub" it stops complaining. Is the
typedef that is done valid or bogus?
---------- Forwarded message ----------
Date: Wed, 4 Jun 1997 14:40:01 -0700 (PDT)
From: James McCarthy <ja...@webengine-db.com>
To: apache-bugdb@apache.org
Cc: apache-bugdb@apache.org
Subject: other/677: Having trouble with compilation of C++ code using some headers.
>Number: 677
>Category: other
>Synopsis: Having trouble with compilation of C++ code using some headers.
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: apache (Apache HTTP Project)
>State: open
>Class: sw-bug
>Submitter-Id: apache
>Arrival-Date: Wed Jun 4 14:40:01 1997
>Originator: jamesm@webengine-db.com
>Organization:
apache
>Release: 1.2b11
>Environment:
I am using the gcc 2.7.2 compiler with SOLARIS 2.5. I am also running into this problem using
the gcc compiler on Linux 2.0 from Redhat.
Solaris uname info:
SunOS aruba.webengine-db.com 5.5 Generic sun4m sparc SUNW,SPARCstation-LX
>Description:
My C++ code will not compile on Solaris or Linux with the GNU GCC 2.7.2 compiler.
The problem seems to be with the pool declarations that are within a struct.
For example the following will compile:
typedef struct {
struct pool *pool;
int elt_size;
int nelts;
int nalloc;
char *elts;
} array_header;
but as it is declared in alloc.h will not (notice the struct declaration in from of pool):
typedef struct {
pool *pool;
int elt_size;
int nelts;
int nalloc;
char *elts;
} array_header;
When I added the struct declaration to all headers that refer to pool within a struct
everything compiled fine and it seemed to have no adverse effect on the normal build of the server in C.
>How-To-Repeat:
Try compiling using a source file that ends with .cpp instead of .c
>Fix:
See description of problem above for how I fixed it on my system. This had to
be added to all header files which declared pool within a struct.
alloc.h, httpd.h http_config.h and buff.
>Audit-Trail:
>Unformatted:
Re: other/677: Having trouble with compilation of C++ code using some headers. (fwd)
Posted by Dean Gaudet <dg...@arctic.org>.
"pool *pool" is valid C, but not valid C++. The need for that difference
is to disambiguate crap like:
{
...
pool; // this is a declaration of "int pool;" and can occur
// anywhere, even after other statements
for (pool = 0; pool < 100; ++pool) {
blah blah(pool);
}
...
}
The guys I worked with who were writing a C++ front-end used to run up to
whiteboards in the office and scribble a construct and challenge
"declaration or statement?" All too frequently you had no idea. The
standard disambiguates all the known ambiguities. Such an excellent
example of language design.
Dean
On Wed, 4 Jun 1997, Marc Slemko wrote:
> If I try to compile a simple C++ program (includes httpd.h and has an
> empty main()), with g++ I get:
>
> In file included from httpd.h:60,
> from test.cc:1:
> alloc.h:105: declaration of identifier `pool' as `struct pool * pool'
> alloc.h:75: conflicts with other use in class as `struct pool'
> In file included from httpd.h:61,
> from test.cc:1:
> buff.h:92: declaration of identifier `pool' as `struct pool * pool'
> alloc.h:75: conflicts with other use in class as `struct pool'
> In file included from test.cc:1:
> httpd.h:415: declaration of identifier `pool' as `struct pool * pool'
> alloc.h:75: conflicts with other use in class as `struct pool'
> httpd.h:534: declaration of identifier `pool' as `struct pool * pool'
> alloc.h:75: conflicts with other use in class as `struct pool'
>
> This appears to be due to namespace conflict.
>
> typedef struct pool pool;
> [...]
> typedef struct {
> pool *pool;
> int elt_size;
> int nelts;
> int nalloc;
> char *elts;
> } array_header;
>
>
> If I change "pool *pool" to "pool *hottub" it stops complaining. Is the
> typedef that is done valid or bogus?
>
> ---------- Forwarded message ----------
> Date: Wed, 4 Jun 1997 14:40:01 -0700 (PDT)
> From: James McCarthy <ja...@webengine-db.com>
> To: apache-bugdb@apache.org
> Cc: apache-bugdb@apache.org
> Subject: other/677: Having trouble with compilation of C++ code using some headers.
>
>
> >Number: 677
> >Category: other
> >Synopsis: Having trouble with compilation of C++ code using some headers.
> >Confidential: no
> >Severity: serious
> >Priority: medium
> >Responsible: apache (Apache HTTP Project)
> >State: open
> >Class: sw-bug
> >Submitter-Id: apache
> >Arrival-Date: Wed Jun 4 14:40:01 1997
> >Originator: jamesm@webengine-db.com
> >Organization:
> apache
> >Release: 1.2b11
> >Environment:
> I am using the gcc 2.7.2 compiler with SOLARIS 2.5. I am also running into this problem using
> the gcc compiler on Linux 2.0 from Redhat.
>
> Solaris uname info:
> SunOS aruba.webengine-db.com 5.5 Generic sun4m sparc SUNW,SPARCstation-LX
> >Description:
> My C++ code will not compile on Solaris or Linux with the GNU GCC 2.7.2 compiler.
>
> The problem seems to be with the pool declarations that are within a struct.
>
> For example the following will compile:
>
> typedef struct {
> struct pool *pool;
> int elt_size;
> int nelts;
> int nalloc;
> char *elts;
> } array_header;
>
> but as it is declared in alloc.h will not (notice the struct declaration in from of pool):
>
> typedef struct {
> pool *pool;
> int elt_size;
> int nelts;
> int nalloc;
> char *elts;
> } array_header;
>
> When I added the struct declaration to all headers that refer to pool within a struct
> everything compiled fine and it seemed to have no adverse effect on the normal build of the server in C.
> >How-To-Repeat:
> Try compiling using a source file that ends with .cpp instead of .c
> >Fix:
> See description of problem above for how I fixed it on my system. This had to
> be added to all header files which declared pool within a struct.
> alloc.h, httpd.h http_config.h and buff.
> >Audit-Trail:
> >Unformatted:
>
>
>