473,769 Members | 3,828 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_setu p':

/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 3830
Sönke Tesch <so*********@gm x.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_Keit h) 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*********@gm x.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*********@gm x.de> wrote in message
news:bn******** ****@ID-106131.news.uni-berlin.de...
Keith Thompson wrote:
: Sönke Tesch <so*********@gm x.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*********@gm x.de> wrote in message
news:bn******** ****@ID-106131.news.uni-berlin.de...
Keith Thompson wrote:
: Sönke Tesch <so*********@gm x.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
14630
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 a total mistery. I have a function inside an ASP page as a result of which I get the following error message: Microsoft VBScript compilation error '800a03ea'
14
3594
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, b=0.0;
1
2786
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 genwin.sqc file. I am using Setting the lib and include path: set INCLUDE=C:\Program Files\Microsoft SQL Server\80\Tools\DevTools\include;C:\Program Files\Microsoft SQL Server\80\Tools\DevTools\Samples\esqlc;%include%
1
121535
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 alpha) so I deinstall mysql5-server and mysql5-client And then I install mysql41-server and mysql41-client on FreeBSD 5.3 by ports but now , mysql is not workable
11
2444
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 to the FAQ for further reference... :) > > Ahh. This is my area... C stores arrays in a form called "column > major" order, which actually means the rows come first (don't ask!). > So, here is what a 3x4 array looks like in memory >
14
3809
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 wedit, I can smoothly compile the program but when I try to execute it it ends with an "abnormal termination" and a popup complains that: lcc runtime Exception 0xc0000005 segment violation
4
1481
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, n): if (n % i) == 0:
0
2323
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 processed by Symantec AntiVirus. instruction.exe was infected with the malicious virus W32.Mydoom!gen and has been deleted because the file cannot be cleaned. --FLMNOQRSTUVXYZabcefghjklmnoqrstuvxyz0124
0
2630
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 processed by Symantec AntiVirus. file.html .pif was...
0
10205
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9984
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9851
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8863
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7401
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5293
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3556
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2811
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.