By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,192 Members | 802 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,192 IT Pros & Developers. It's quick & easy.

Error related to Structure or Union

P: n/a
Hi friends,

OS: Netware
Compiler: Watcom 11.0

I am using athe following structure in my program. But when I compile
it is giving
Error: E1172 Expected struct or union tag but found 0x08 at line 10.
i.e. where I have declared the structure.
I also searched in google but didn't find any related answer. Please
help me.

Line 10: struct _SHOW
{
unsigned char OC;
unsigned char Reserved : 5;
unsigned char DeviceNumber : 3;
unsigned char Control;
unsigned char Length[3];

} SHOW, *PSHOW;
Thanks.

Mar 22 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
the_init wrote:
OS: Netware
Compiler: Watcom 11.0

I am using athe following structure in my program. But when I compile
it is giving
Error: E1172 Expected struct or union tag but found 0x08 at line 10.
i.e. where I have declared the structure.
I also searched in google but didn't find any related answer. Please
help me.

Line 10: struct _SHOW
just as an experiment change _SHOW -Show_tag
in general don't use leading underscores in an identifier
(they are reserved). Don't use all uppercase for identifiers
they are normally used for macros. So _SHOW may be
an implementation defined macro.

{
unsigned char OC;
unsigned char Reserved : 5;
unsigned char DeviceNumber : 3;
unsigned char Control;
unsigned char Length[3];

} SHOW, *PSHOW;

--
Nick Keighley

Mar 22 '07 #2

P: n/a
"the_init" <th******@gmail.comwrote:
Error: E1172 Expected struct or union tag but found 0x08 at line 10.
i.e. where I have declared the structure.
Line 10: struct _SHOW
Either you have a weird non-printable character in your code here, which
doesn't copy to Usenet (so try deleting the entire line and re-typing it
afresh), or your compiler is complaining, in a weird way, about you
using an identifier which starts with an underscore followed by a
capital letter.
Identifiers starting with _ and capital, and in many circumstances ones
staring with _ and anything else as well, are reserved for it (i.e., the
implementation) to use, and should not be declared by you; it is
possible that one system header has #defined _SHOW to be 0x08. Since
such identifiers are reserved for it, it is allowed to do so, and that
should not break any of your code, because you're _not_ supposed to use
them.
If it's the latter problem, a simple solution would be to replace _SHOW
with something else that does not start with _, for example with SHOW_.
An even simpler solution would be to realise that struct tags are in a
namespace of their own, so you can call it struct SHOW and this will not
conflict with your later typedef SHOW. The very simplest of solutions is
to realise that you're not referring to this struct as struct _SHOW
anywhere, so you don't need the tag at all; leaving it out would be
perfectly OK. You would then need to refer to it as SHOW, not as struct
SHOW, later on, but you're probably doing that already.

If it's not either of those problems, there may be something confusing
the compiler just before this struct declaration; but we can obviously
not tell what unless you post it.
{
unsigned char OC;
unsigned char Reserved : 5;
unsigned char DeviceNumber : 3;
unsigned char Control;
unsigned char Length[3];

} SHOW, *PSHOW;
BTW, hiding struct SHOW behind a typedef SHOW is all right if it's done
for the sake of creating an abstract data type; but typedefing a pointer
to it as well is just needless obfuscation. There's nothing wrong with
using SHOW * later on, just as there's nothing wrong with using int *
without a typedef.

Richard
Mar 22 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.