|
|||
|
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, |
|
|
||||
|
||||
|
|
|
|||
|
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. |
|
|||
|
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 |
|
|||
|
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. |
|
|||
|
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 |
|
|||
|
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 |
|
|||
|
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" |
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|