Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > error: expected declaration specifiers or '...' before 'Value'

Reply
Thread Tools

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

 
 
Li Zhou
Guest
Posts: n/a
 
      03-17-2012
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
 
 
 
 
Li Zhou
Guest
Posts: n/a
 
      03-17-2012
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
 
 
 
 
Eric Sosman
Guest
Posts: n/a
 
      03-17-2012
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
http://www.velocityreviews.com/forums/(E-Mail Removed)d
 
Reply With Quote
 
Ben Bacarisse
Guest
Posts: n/a
 
      03-17-2012
Li Zhou <(E-Mail Removed)> 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
 
Nobody
Guest
Posts: n/a
 
      03-17-2012
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
 
Kleuske
Guest
Posts: n/a
 
      03-18-2012
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
 
Keith Thompson
Guest
Posts: n/a
 
      03-18-2012
Kleuske <(E-Mail Removed)> 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) (E-Mail Removed) <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

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 On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Declaration specifiers cp C Programming 6 07-16-2006 04:30 PM
declaration expected Simon Harris ASP .Net 2 10-03-2004 09:03 PM
Declaration Expected? D. Shane Fowlkes ASP .Net 9 11-24-2003 12:45 PM
error "declaration expected" for (Response.ContentType = "application/pdf") TJS ASP .Net 5 11-19-2003 12:25 AM
BC30188 Declaration Expected Ammar_ace ASP .Net 1 08-21-2003 02:30 PM



Advertisments