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

L

Li Zhou

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,
 
L

Li Zhou

pete said:
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.
 
E

Eric Sosman

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.)
 
B

Ben Bacarisse

Li Zhou said:
Hello, i need help fix this compile error
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.
 
K

Kleuske

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.
 
K

Keith Thompson

Kleuske said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top