473,396 Members | 1,773 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.

Don't understand syntax error

I'm getting this error report from my compiler (MSVC++ 7):

c:\Eiffel55\library\cjs\pdf\spec\include\p_intern. h(258) : error C2143:
syntax error : missing ')' before '*'

Here's the code:
struct PDF_s {
/* -------------------------- general stuff ------------------------ */
unsigned long magic; /* poor man's integrity check */
void (*freeproc)(PDF *p, void *mem);
pdc_core *pdc; /* core context */
....
....
};

I removed all code one line after the error line.
The reported error line is:

void (*freeproc)(PDF *p, void *mem);

I am not an expert in C but I believe I have a reasonable understanding
but I cannot see a problem with this line.

Could anyone help?
--
Regards
Chris Saunders
Nov 14 '05 #1
9 2008
"Chris Saunders" <ch************@sympatico.ca> wrote in message
news:dt*****************@news20.bellglobal.com...
I'm getting this error report from my compiler (MSVC++ 7):

c:\Eiffel55\library\cjs\pdf\spec\include\p_intern. h(258) : error C2143:
syntax error : missing ')' before '*'

Here's the code: [snip] The reported error line is:

void (*freeproc)(PDF *p, void *mem);


Because the code you provided is incomplete, it seems that only a guess is
possible. My guess, FWIW, is that it has something to do with "PDF".

Alex
Nov 14 '05 #2

Chris Saunders wrote:
I'm getting this error report from my compiler (MSVC++ 7):

c:\Eiffel55\library\cjs\pdf\spec\include\p_intern. h(258) : error C2143: syntax error : missing ')' before '*'
what's the line of 258?

maybe you have to declare the PDF struct before struct PDF_s

Here's the code:
struct PDF_s {
/* -------------------------- general stuff ------------------------ */ unsigned long magic; /* poor man's integrity check */ void (*freeproc)(PDF *p, void *mem);
pdc_core *pdc; /* core context */
...
...
};

I removed all code one line after the error line.
The reported error line is:

void (*freeproc)(PDF *p, void *mem);

I am not an expert in C but I believe I have a reasonable understanding but I cannot see a problem with this line.

Could anyone help?
--
Regards
Chris Saunders


Nov 14 '05 #3

Chris Saunders wrote:
I'm getting this error report from my compiler (MSVC++ 7):

c:\Eiffel55\library\cjs\pdf\spec\include\p_intern. h(258) : error C2143: syntax error : missing ')' before '*'

Here's the code:
struct PDF_s {
/* -------------------------- general stuff ------------------------ */ unsigned long magic; /* poor man's integrity check */ void (*freeproc)(PDF *p, void *mem);
pdc_core *pdc; /* core context */
...
...
};

I removed all code one line after the error line.
The reported error line is:

void (*freeproc)(PDF *p, void *mem);

I am not an expert in C but I believe I have a reasonable understanding but I cannot see a problem with this line.

Could anyone help?
--
Regards
Chris Saunders
Hi,

I think the line...
void (*freeproc)(PDF *p, void *mem);


should be...

void (*freeproc)(struct PDF *p, void *mem);

I haven't tried compiling since I donot have VC 7.

-vs_p

Nov 14 '05 #4
I am just making a guess here.

Have you already declared PDF before using it in
void (*freeproc)(PDF *p, void *mem);

It would help if you could let us have the defintion of PDF ?

Having a struct keyword or not before PDF should not make a difference
though.

Nov 14 '05 #5
In article <dt*****************@news20.bellglobal.com>
Chris Saunders <ch************@sympatico.ca> wrote:

[snippage]
struct PDF_s {
void (*freeproc)(PDF *p, void *mem);
};
[produces a syntax error on the middle of the three above lines]
Could anyone help?


See <http://web.torek.net/torek/c/types2.html>, paying particular
attention to the ordering rules for using typedefs (near the bottom
of the article). The typedef line I see in my crystal ball:

typedef struct PDF_s PDF;

must come *before* the definition of the structure.
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
Nov 14 '05 #6
"Jaspreet" <js***********@gmail.com> writes:
I am just making a guess here.

Have you already declared PDF before using it in
void (*freeproc)(PDF *p, void *mem);

It would help if you could let us have the defintion of PDF ?

Having a struct keyword or not before PDF should not make a difference
though.


Yes, it does. If you have a type "struct PDF", you can't refer to it
as "PDF", unless PDF happens to be a typedef for struct PDF. If your
compiler allows you to do so, it's not a C compiler (it's probably a
C++ compiler).

In the code fragment posted by the OP, there's nothing called either
"PDF" or "struct PDF", just a "struct PDF_s".

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #7

Keith Thompson wrote:
"Jaspreet" <js***********@gmail.com> writes:
I am just making a guess here.

Have you already declared PDF before using it in
void (*freeproc)(PDF *p, void *mem);

It would help if you could let us have the defintion of PDF ?

Having a struct keyword or not before PDF should not make a difference though.


Yes, it does. If you have a type "struct PDF", you can't refer to it
as "PDF", unless PDF happens to be a typedef for struct PDF. If your
compiler allows you to do so, it's not a C compiler (it's probably a
C++ compiler).

I agree to your statement. However, I guess you canot have a function
decl. inside a struct in C. Let me know what I am missing here. I am
using gcc 3.3.2. If I make the file as .c file the compiler complains
about
field declared as a function.

However changing the extension to .cc lets me compile correctly.

So to summarise a function block inside a struct is not allowed in C.
Let me know if I am wrong.

Nov 14 '05 #8
"Jaspreet" <js***********@gmail.com> writes:
[...]
I agree to your statement. However, I guess you canot have a function
decl. inside a struct in C. Let me know what I am missing here. I am
using gcc 3.3.2. If I make the file as .c file the compiler complains
about
field declared as a function.

However changing the extension to .cc lets me compile correctly.

So to summarise a function block inside a struct is not allowed in C.
Let me know if I am wrong.


It's correct that you can't declare a function inside a struct declaration.

As for what C++ allows, that's a question for comp.lang.c++ (or,
better yet, for your C++ textbook).

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #9
Jaspreet wrote:
.... snip ...
I agree to your statement. However, I guess you canot have a
function decl. inside a struct in C. Let me know what I am
missing here. I am using gcc 3.3.2. If I make the file as .c file
the compiler complains about field declared as a function.

However changing the extension to .cc lets me compile correctly.


No it doesn't. It just causes the compiler to treat it as C++,
which is another language and has different rules. We don't
discuss C++ here.

--
Some informative links:
news:news.announce.newusers
http://www.geocities.com/nnqweb/
http://www.catb.org/~esr/faqs/smart-questions.html
http://www.caliburn.nl/topposting.html
http://www.netmeister.org/news/learn2quote.html
Nov 14 '05 #10

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

Similar topics

303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
20
by: Sam | last post by:
Hi I'm learning to code with C++ and wrote some very simple code. I think it's consistent with every rule but always got compiling errors that I don't understand. The code include 5 files as...
5
by: Danny Anderson | last post by:
Hola- I didn't get any responses on a previous post, so I am trying to reword my problem and post compile-able code that exhibits the behavior I am describing. On the second iteration of the...
5
by: rashmi | last post by:
Hello All, tp.c:107: error: syntax error before '*' token tp.c:108: warning: function declaration isn't a prototype tp.c:121: error: syntax error before '*' token tp.c:122: warning: function...
19
by: so many sites so little time | last post by:
the table is head the colunm is called body <?php //show_site.php // This script retrieves blog entries from the database. // Address error handing. ini_set ('display_errors', 1);...
20
by: Wes Groleau | last post by:
I was doing update statements in SQL Server 2000. I have a table with over 16 million rows. It came from several hundred delimited text files, and two of the columns are file ID (int) and Line...
8
by: Joshua Moore | last post by:
/* Hi, I was hoping someone could help me with this problem. I did my work and worked my way through the usual compiler messages, but I have run against some problem I can't identify. The compiler...
0
by: Stef Mientki | last post by:
hello, I've syntax error which I totally don't understand: ########## mainfile : import test_upframe2 if __name__ == '__main__': var1 = 33 code = 'print var1 + 3 \n'
0
by: Stef Mientki | last post by:
Terry Reedy wrote: sorry, don't know how this happened, as I always copy/paste ? AFAIK locals() == sys._getframe(0).f_locals AFAIK, again one level up weird, I use it in 2.5 and if I remember...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
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.