473,396 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Weird syntax error with gcc and FreeBSD

Hi everybody,

I have a problem with the following piece of code:

141: /* A data block to manage a single log target: */
142: typedef struct {
143: apr_reslist_t *dbs; /* connection pool */
144:
145: const char *uri; /* the complete log uri.. */

This compiles fine (using gcc 3.2.2 through Apache 2 apxs) on Linux, but
it breaks on some other guy's FreeBSD (again using apxs/gcc, but unknown
gcc version):

/usr/local/libexec/apache2/mod_log_mysql.c:143: syntax error before
'apr_reslist_t'

/usr/local/libexec/apache2/mod_log_mysql.c: In function 'mysql_log_setup':

/usr/local/libexec/apache2/mod_log_mysql.c:210: structure has no member named
'dbs'
[and more "unknown member dbs"..]

No idea what's wrong with line 142 or 143. At first I thought this might be a
problem with apr_reslist_t being unknown but after changing apr_reslist_t to
xxxapr_reslist_t it dumps other errors than the ones above.
Then I tried a slightly different line 141:

141: typedef struct s_log_mysql {

Doesn't help either.

Any ideas? I cannot imagine that this is some gcc incompatibility, at least
it seems to me like standard C code.

The complete mod_log_mysql.c code is available at
http://bitbrook.de/software/mod_log_...od_log_mysql.c .

Thanks a lot, any help appreciated!
soenk.e

Nov 13 '05 #1
5 3806
Sönke Tesch <so*********@gmx.de> writes:
Hi everybody,

I have a problem with the following piece of code:

141: /* A data block to manage a single log target: */
142: typedef struct {
143: apr_reslist_t *dbs; /* connection pool */
144:
145: const char *uri; /* the complete log uri.. */

This compiles fine (using gcc 3.2.2 through Apache 2 apxs) on Linux, but
it breaks on some other guy's FreeBSD (again using apxs/gcc, but unknown
gcc version):

/usr/local/libexec/apache2/mod_log_mysql.c:143: syntax error before
'apr_reslist_t'


Presumably apr_reslist_t is a typedef. It looks like you're missing
the declaration of apr_reslist_t on FreeBSD.

It's certainly annoying that the compiler gives you a syntax error
rather than letting you know that apr_reslist_t is an undeclared
identifier. This is because of the way typedefs are defined in the
language. Each typedef name is effectively a new keyword. Since
apr_reslist_t isn't declared, it's just an identifier, and you can't
use a (non-typedef) identifier as a type name.

--
Keith Thompson (The_Other_Keith) ks*@cts.com <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"
Nov 13 '05 #2
Keith Thompson wrote:
: Sönke Tesch <so*********@gmx.de> writes:

: > 142: typedef struct {
: > 143: apr_reslist_t *dbs; /* connection pool */

: > /usr/local/libexec/apache2/mod_log_mysql.c:143: syntax error before
: >'apr_reslist_t'

: Presumably apr_reslist_t is a typedef.

Yes, it's in the Apache Portable Runtime utilities, apr_reslist.h:

/** Opaque resource list object */
typedef struct apr_reslist_t apr_reslist_t;

The file apr_reslist.h is definitly #included, since everything else
used from it is accepted. I also doubt that the Apache group made a
mistake here - at least the Apache webserver is available for FreeBSD,
so it must work :)

: It looks like you're missing
: the declaration of apr_reslist_t on FreeBSD.

That was my first thought, but gcc prints "parse error" (not "syntax
error") and three dozens of other messages about missing semicolons
and other stuff if it encounters an unknown item.
Here, it just complains about the wrong syntax in line 143 and later
about the undefined "dbs" field whenever it's accessed (makes sense
to me since the dbs declaration failed).

: Since
: apr_reslist_t isn't declared, it's just an identifier, and you can't
: use a (non-typedef) identifier as a type name.

Might there be a problem with the typedef declaration from apr_reslist.h
quoted above? I have to admit that I do not understand that double
apr_reslist_t-part there :]

Regards,
soenk.e

Nov 13 '05 #3

"Sönke Tesch" <so*********@gmx.de> wrote in message
news:bn************@ID-106131.news.uni-berlin.de...
Keith Thompson wrote:
: Sönke Tesch <so*********@gmx.de> writes:

: > 142: typedef struct {
: > 143: apr_reslist_t *dbs; /* connection pool */

: > /usr/local/libexec/apache2/mod_log_mysql.c:143: syntax error before
: >'apr_reslist_t'

: Presumably apr_reslist_t is a typedef.

Yes, it's in the Apache Portable Runtime utilities, apr_reslist.h:

/** Opaque resource list object */
typedef struct apr_reslist_t apr_reslist_t;

The file apr_reslist.h is definitly #included, since everything else
used from it is accepted. I also doubt that the Apache group made a
mistake here - at least the Apache webserver is available for FreeBSD,
so it must work :)

: It looks like you're missing
: the declaration of apr_reslist_t on FreeBSD.

That was my first thought, but gcc prints "parse error" (not "syntax
error") and three dozens of other messages about missing semicolons
and other stuff if it encounters an unknown item.
Here, it just complains about the wrong syntax in line 143 and later
about the undefined "dbs" field whenever it's accessed (makes sense
to me since the dbs declaration failed).

: Since
: apr_reslist_t isn't declared, it's just an identifier, and you can't
: use a (non-typedef) identifier as a type name.

Might there be a problem with the typedef declaration from apr_reslist.h
quoted above? I have to admit that I do not understand that double
apr_reslist_t-part there :]

Regards,
soenk.e

take a look at this message - it mentions that the default value(in apr.h)
for APR_HAS_THREADS is 0(or at least was at one point in history) which
would exclude the definition of apr_reslist_t - which would probably lead to
the behavour you are seeing.

http://blade.nagaokaut.ac.jp/cgi-bin...uby-talk/72610
Nov 13 '05 #4

"Sönke Tesch" <so*********@gmx.de> wrote in message
news:bn************@ID-106131.news.uni-berlin.de...
Keith Thompson wrote:
: Sönke Tesch <so*********@gmx.de> writes:

: > 142: typedef struct {
: > 143: apr_reslist_t *dbs; /* connection pool */

: > /usr/local/libexec/apache2/mod_log_mysql.c:143: syntax error before
: >'apr_reslist_t'

: Presumably apr_reslist_t is a typedef.

Yes, it's in the Apache Portable Runtime utilities, apr_reslist.h:

/** Opaque resource list object */
typedef struct apr_reslist_t apr_reslist_t;
(snip)
: Since
: apr_reslist_t isn't declared, it's just an identifier, and you can't
: use a (non-typedef) identifier as a type name.

Might there be a problem with the typedef declaration from apr_reslist.h
quoted above? I have to admit that I do not understand that double
apr_reslist_t-part there :]


It typedefs the type (struct apr_reslist_t) to apr_reslist_t, which saves
having to type struct all over. The struct namespace is separate from the
typedef namespace, so you can do that. Though if struct apr_reslist_t isn't
defined, then the typedef won't work.

It might be that you are allowed to typedef the struct before defining the
struct, so that the compiler wouldn't issue an error message yet.

-- glen
Nov 13 '05 #5
Peter Slootweg wrote:
: take a look at this message - it mentions that the default value(in apr.h)
: for APR_HAS_THREADS is 0(or at least was at one point in history) which
: would exclude the definition of apr_reslist_t - which would probably lead to
: the behavour you are seeing.

No, #if is already used instead of #ifdef, that wasn't the problem.

Despite the different error messages on FreeBSD and Linux the problem was in
fact a missing apr_reslist_t declaration, just as Keith already mentioned.
The cause is that Apache Portable Runtime thread support is normally disabled
on FreeBSD because of some incompatibility. apr_reslist however depends on
threads, so they excluded the complete apr_reslist with '#if APR_HAS_THREADS'.
That's why compilation fails on FreeBSD but not on Linux.

But thanks anyway, Keith, Peter and Glen!
soenk.e

Nov 13 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: NanQuan | last post by:
I'm hoping someone can help me solve this error since I am at a total loss here. Usually I don't bother posting on any forums or groups on the internet and prefer to solve stuff myself but this is...
14
by: Bo | last post by:
When I had this code, a and b's value never increases. for( int i=0, double a=0.0, double b=0.0 ; i<100; a+=0.1, b+=0.2 ) { printf( "%s\n", i+a+b ); } This works, however: double a=0.0,...
1
by: amit | last post by:
I am trying to compile the sample program genwin.sqc, using nsqlprep which is used to precompile embedded sql in C. I am getting weird errors and that is because windows.h is included in the...
1
by: jiing | last post by:
Now let me describe what I have done and my purpose: Originally, I want to user ports to install phpBB But I found that phpBB doesn't support mysql 5.x (but the ports installed mySQL 5.0.0...
11
by: Mr. Berserker | last post by:
I was posting stuff to a mailing list when a friend, Prof. Corbessero and I came up with this one. Perhaps you can help resolve this, or add anything else worth knowing?? Maybe it should be added...
14
by: vittorio | last post by:
While I can compile the program below under freebsd via a simple: gcc prog1.c -o prog1 and it runs smoothly, I'm experiencing annoying problems with lcc-win32 under windows xp pro. In fact, under...
4
by: jedi200581 | last post by:
Hi, I'm new at python as I just started to learn it, but I found out something weird. I have wrote a little program to compute Mersenne number: # Snipet on def is_prime n: for i in range(2,...
0
by: MAILER-DAEMON | last post by:
This is a multi-part message in MIME format. --FLMNOQRSTUVXYZabcefghjklmnoqrstuvxyz0124 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit This message has been...
0
by: MAILER-DAEMON | last post by:
This is a multi-part message in MIME format. --HKLMNNOPQQRSTUUVWXXYZaabcdeffghiijklmmno Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit This message has been...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.