Go Back   Rhinocerus > Newsgroup > Newsgroup comp.lang.c

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 03-17-2012, 11:12 AM
Li Zhou
Guest
 
Posts: n/a
Default error: expected declaration specifiers or '...' before 'Value'

Hello, i need help fix this compile error

error: expected declaration specifiers or '...' before 'Value'

where Value is defined in another header, say "a.h"

in "a.h"
-------------------------------------------
typedef struct {
int type;
ssize_t size;
char* data;
} Value;
-------------------------------------------

in "b.h"
-------------------------------------------
#include "a.h"

int applypatch(const char* source_filename,
const char* target_filename,
const char* target_sha1_str,
size_t target_size,
int num_patches,
char** const patch_sha1_str,
Value** patch_data);
-------------------------------------------

the compile error occurs at b.h saying

error: expected declaration specifiers or '...' before 'Value'

but Value is already defined by the typedef clause in a.h, so what is
the problem here and how do i fix this?

Regards,






Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

  #2 (permalink)  
Old 03-17-2012, 11:31 AM
Li Zhou
Guest
 
Posts: n/a
Default Re: error: expected declaration specifiers or '...' before 'Value'

pete wrote:
> Li Zhou wrote:
>>
>> Hello, i need help fix this compile error
>>
>> error: expected declaration specifiers or '...' before 'Value'
>>
>> where Value is defined in another header, say "a.h"
>>
>> in "a.h"
>> -------------------------------------------
>> typedef struct {
>> int type;
>> ssize_t size;
>> char* data;
>> } Value;
>> -------------------------------------------
>>
>> in "b.h"
>> -------------------------------------------
>> #include "a.h"
>>
>> int applypatch(const char* source_filename,
>> const char* target_filename,
>> const char* target_sha1_str,
>> size_t target_size,
>> int num_patches,
>> char** const patch_sha1_str,
>> Value** patch_data);
>> -------------------------------------------
>>
>> the compile error occurs at b.h saying
>>
>> error: expected declaration specifiers or '...' before 'Value'
>>
>> but Value is already defined by the typedef clause in a.h, so what is
>> the problem here and how do i fix this?

>
> Where are ssize_t and size_t defined?
>


in <sys/types.h>

i have manually added #include <sys/types.h> to "a.h" but the compile
error is still there.


Reply With Quote
  #3 (permalink)  
Old 03-17-2012, 11:56 AM
Eric Sosman
Guest
 
Posts: n/a
Default Re: error: expected declaration specifiers or '...' before 'Value'

On 3/17/2012 8:31 AM, Li Zhou wrote:
> pete wrote:
>> Li Zhou wrote:
>>>
>>> Hello, i need help fix this compile error
>>>
>>> error: expected declaration specifiers or '...' before 'Value'
>>>
>>> where Value is defined in another header, say "a.h"
>>>
>>> in "a.h"
>>> -------------------------------------------
>>> typedef struct {
>>> int type;
>>> ssize_t size;
>>> char* data;
>>> } Value;
>>> -------------------------------------------
>>>
>>> in "b.h"
>>> -------------------------------------------
>>> #include "a.h"
>>>
>>> int applypatch(const char* source_filename,
>>> const char* target_filename,
>>> const char* target_sha1_str,
>>> size_t target_size,
>>> int num_patches,
>>> char** const patch_sha1_str,
>>> Value** patch_data);
>>> -------------------------------------------
>>>
>>> the compile error occurs at b.h saying
>>>
>>> error: expected declaration specifiers or '...' before 'Value'
>>>
>>> but Value is already defined by the typedef clause in a.h, so what is
>>> the problem here and how do i fix this?

>>
>> Where are ssize_t and size_t defined?
>>

>
> in <sys/types.h>


Not a Standard C header; who knows what it might do?

> i have manually added #include <sys/types.h> to "a.h" but the compile
> error is still there.


I think pete's point is that you should show us an *exact*
and *complete* example. This isn't a request to post all twenty
source files and their ten thousand lines, but a request for a
short, complete, and self-contained code sample. (Since ssize_t
is not defined by any Standard header, you'll have to remove it
from the example you post; other things that are not germane to
the problem can also be removed. You should be able to get the
whole thing down to about ten lines between the two files and
still get the error message. If you snip away something that's
"obviously not related" and the message suddenly goes away, you'll
have gained an important clue.)

--
Eric Sosman
esosman@ieee-dot-org.invalid
Reply With Quote
  #4 (permalink)  
Old 03-17-2012, 12:17 PM
Ben Bacarisse
Guest
 
Posts: n/a
Default Re: error: expected declaration specifiers or '...' before 'Value'

Li Zhou <zhou3@lycos.com> writes:

> Hello, i need help fix this compile error

<snip>
> but Value is already defined by the typedef clause in a.h, so what is
> the problem here and how do i fix this?


Let me add a slightly different perspective. You are clearly baffled,
but by posting those bits of the code that baffle you, you are just
passing the bafflement onto us.

In other words, when you are suspicious of some code, by all means post
just that code -- 9 times out of 10 the problem will be clear to someone
else. But when you are puzzled because it all seems so obvious, 9 times
out of 10, the problem is not where you think it is and you have to post
a complete example.

--
Ben.
Reply With Quote
  #5 (permalink)  
Old 03-17-2012, 12:19 PM
pete
Guest
 
Posts: n/a
Default Re: error: expected declaration specifiers or '...' before 'Value'

Li Zhou wrote:
>
> Hello, i need help fix this compile error
>
> error: expected declaration specifiers or '...' before 'Value'
>
> where Value is defined in another header, say "a.h"
>
> in "a.h"
> -------------------------------------------
> typedef struct {
> int type;
> ssize_t size;
> char* data;
> } Value;
> -------------------------------------------
>
> in "b.h"
> -------------------------------------------
> #include "a.h"
>
> int applypatch(const char* source_filename,
> const char* target_filename,
> const char* target_sha1_str,
> size_t target_size,
> int num_patches,
> char** const patch_sha1_str,
> Value** patch_data);
> -------------------------------------------
>
> the compile error occurs at b.h saying
>
> error: expected declaration specifiers or '...' before 'Value'
>
> but Value is already defined by the typedef clause in a.h, so what is
> the problem here and how do i fix this?


Where are ssize_t and size_t defined?

--
pete
Reply With Quote
  #6 (permalink)  
Old 03-17-2012, 02:18 PM
Nobody
Guest
 
Posts: n/a
Default Re: error: expected declaration specifiers or '...' before 'Value'

On Sat, 17 Mar 2012 20:12:55 +0800, Li Zhou wrote:

> so what is the problem here


The problem is that you're not posting the actual code which is causing
problems.

Reply With Quote
  #7 (permalink)  
Old 03-18-2012, 11:13 AM
Kleuske
Guest
 
Posts: n/a
Default Re: error: expected declaration specifiers or '...' before 'Value'

On Sat, 17 Mar 2012 20:12:55 +0800, Li Zhou saw fit to publish the
following:

> Hello, i need help fix this compile error
>
> error: expected declaration specifiers or '...' before 'Value'
>
> where Value is defined in another header, say "a.h"
>
> in "a.h"
> ------------------------------------------- typedef struct {
> int type;
> ssize_t size;
> char* data;
> } Value;
> -------------------------------------------
>
> in "b.h"
> ------------------------------------------- #include "a.h"
>
> int applypatch(const char* source_filename,
> const char* target_filename,
> const char* target_sha1_str,
> size_t target_size,
> int num_patches,
> char** const patch_sha1_str,
> Value** patch_data);
> -------------------------------------------
>
> the compile error occurs at b.h saying
>
> error: expected declaration specifiers or '...' before 'Value'
>
> but Value is already defined by the typedef clause in a.h, so what is
> the problem here and how do i fix this?
>
> Regards,


Did you #include a.h in b.h? If not, the compiler has a point.

--
You! What PLANET is this!
-- McCoy, "The City on the Edge of Forever", stardate 3134.0
Reply With Quote
  #8 (permalink)  
Old 03-18-2012, 09:58 PM
Keith Thompson
Guest
 
Posts: n/a
Default Re: error: expected declaration specifiers or '...' before 'Value'

Kleuske <kleuske@nowhere.net> writes:
> On Sat, 17 Mar 2012 20:12:55 +0800, Li Zhou saw fit to publish the
> following:
>
>> Hello, i need help fix this compile error
>>
>> error: expected declaration specifiers or '...' before 'Value'
>>
>> where Value is defined in another header, say "a.h"

[...]
>> in "b.h"
>> ------------------------------------------- #include "a.h"
>>
>> int applypatch(const char* source_filename,
>> const char* target_filename,
>> const char* target_sha1_str,
>> size_t target_size,
>> int num_patches,
>> char** const patch_sha1_str,
>> Value** patch_data);
>> -------------------------------------------
>>
>> the compile error occurs at b.h saying
>>
>> error: expected declaration specifiers or '...' before 'Value'
>>
>> but Value is already defined by the typedef clause in a.h, so what is
>> the problem here and how do i fix this?
>>
>> Regards,

>
> Did you #include a.h in b.h? If not, the compiler has a point.


Yes. It's right there in the quoted article, but somehow your
newsreader (or something) joined it with the previous line.

--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Reply With Quote
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT. The time now is 08:48 AM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.