CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

"Expecting a (" error on a struct/union operati

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Jeff King
Guest







"Expecting a (" error on a struct/union operati
PostPosted: Mon May 05, 2003 3:43 pm     Reply with quote

Getting Error message "Expecting a (" on the following code snippet. If I comment out the initialzation at the end, it compiles OK, this appears to be the issue. There is no function called "frequency" and I have even tried to rename this.

Compiler version is 3.148 for 18F442. I even reloaded PCWH on another machine thinking something might be corrupted. Same problem. OS is WinXP. Also took out all signed math and tried to duplication Hans Wedemyer's example. See below.


-----
signed long Channel[16] =
{
-25800 // Channel 0 902.1 mhz -12900khz
-21800 // Channel 1 904.1 mhz -10900khz
-17800 // Channel 2 906.1 mhz -8900khz
-13800 // Channel 3 908.1 mhz -6900khz
-9800 // Channel 4 910.1 mhz -4900khz
-5800 // Channel 5 912.1 mhz -2900khz
-3800 // Channel 6 913.6 mhz -1400khz
0 // Channel 7 915.0 mhz N channel is all 0's, two's complement above and below
3000 // Channel 8 916.5 mhz 1500khz
4200 // Channel 9 917.1 mhz 2100khz
5200 // Channel 10 917.6 mhz 2600khz
8200 // Channel 11 919.1 mhz 4100khz
12200 // Channel 12 921.1 mhz 6100khz
16200 // Channel 13 923.1 mhz 8100khz
20200 // Channel 14 925.1 mhz 10100khz
24200 // Channel 15 927.1 mhz 12100khz
};


struct FreqS
{
unsigned char Param2;
unsigned char Param3;
};

union
{
signed long LS;
struct FreqS FS;
}frequency;

//frequency.LS = Channel[7];

OR

//frequency.LS = 0x0000;

OR

// frequency.LS = -100;

All give the error message.


Any thoughts?
___________________________
This message was ported from CCS's old forum
Original Post ID: 14199
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: "Expecting a (" error on a struct/union ope
PostPosted: Mon May 05, 2003 4:04 pm     Reply with quote

:=Getting Error message "Expecting a (" on the following code snippet. If I comment out the initialzation at the end, it compiles OK, this appears to be the issue. There is no function called "frequency" and I have even tried to rename this.
:=
:=//frequency.LS = Channel[7];
:=
:=//frequency.LS = 0x0000;
:=
:=// frequency.LS = -100;
:=
-----------------------------------------------------
Are you trying to put these three lines above main() ?
That will cause the error. They must be within main()
or some other function.
___________________________
This message was ported from CCS's old forum
Original Post ID: 14200
Jeff King
Guest







Re: "Expecting a (" error on a struct/union ope
PostPosted: Mon May 05, 2003 4:32 pm     Reply with quote

Yeap, that was it. Too bad the error message didn't reflect the correct error (and CCS (and KR implies) that you can't initialize Unions outside of a function).

Thanks

-Jeff


:=:=Getting Error message "Expecting a (" on the following code snippet. If I comment out the initialzation at the end, it compiles OK, this appears to be the issue. There is no function called "frequency" and I have even tried to rename this.
:=:=
:=:=//frequency.LS = Channel[7];
:=:=
:=:=//frequency.LS = 0x0000;
:=:=
:=:=// frequency.LS = -100;
:=:=
:=-----------------------------------------------------
:=Are you trying to put these three lines above main() ?
:=That will cause the error. They must be within main()
:=or some other function.
___________________________
This message was ported from CCS's old forum
Original Post ID: 14201
R.J.Hamlett
Guest







Re: "Expecting a (" error on a struct/union ope
PostPosted: Tue May 06, 2003 3:32 am     Reply with quote

:=Getting Error message "Expecting a (" on the following code snippet. If I comment out the initialzation at the end, it compiles OK, this appears to be the issue. There is no function called "frequency" and I have even tried to rename this.
:=
:=Compiler version is 3.148 for 18F442. I even reloaded PCWH on another machine thinking something might be corrupted. Same problem. OS is WinXP. Also took out all signed math and tried to duplication Hans Wedemyer's example. See below.
:=
:=
:=-----
:=signed long Channel[16] =
:={
:= -25800 // Channel 0 902.1 mhz -12900khz
:= -21800 // Channel 1 904.1 mhz -10900khz
:= -17800 // Channel 2 906.1 mhz -8900khz
:= -13800 // Channel 3 908.1 mhz -6900khz
:= -9800 // Channel 4 910.1 mhz -4900khz
:= -5800 // Channel 5 912.1 mhz -2900khz
:= -3800 // Channel 6 913.6 mhz -1400khz
:= 0 // Channel 7 915.0 mhz N channel is all 0's, two's complement above and below
:= 3000 // Channel 8 916.5 mhz 1500khz
:= 4200 // Channel 9 917.1 mhz 2100khz
:= 5200 // Channel 10 917.6 mhz 2600khz
:= 8200 // Channel 11 919.1 mhz 4100khz
:= 12200 // Channel 12 921.1 mhz 6100khz
:= 16200 // Channel 13 923.1 mhz 8100khz
:= 20200 // Channel 14 925.1 mhz 10100khz
:= 24200 // Channel 15 927.1 mhz 12100khz
:=};
:=
:=
:=struct FreqS
:={
:=unsigned char Param2;
:=unsigned char Param3;
:=};
:=
:=union
:={
:=signed long LS;
:=struct FreqS FS;
:=}frequency;
:=
:=//frequency.LS = Channel[7];
:=
:=OR
:=
:=//frequency.LS = 0x0000;
:=
:=OR
:=
:=// frequency.LS = -100;
:=
:=All give the error message.
:=
:=
:=Any thoughts?
Compiles OK for me, on the same compiler version, with the code cut and pasted from the above...
Look carefully immediately in front of the actual definitions posted. For instance, if there is a structure declared the line 'ahead' of the first structure definition, and it has it's ';' missing, it may be that this definition is being 'included' in the one ahead of it (which would still apply if you changed the name), resulting in the compiler getting confused.

Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 14206
R.J.Hamlett
Guest







Re: "Expecting a (" error on a struct/union ope
PostPosted: Tue May 06, 2003 3:35 am     Reply with quote

:=:=Getting Error message "Expecting a (" on the following code snippet. If I comment out the initialzation at the end, it compiles OK, this appears to be the issue. There is no function called "frequency" and I have even tried to rename this.
:=:=
:=:=//frequency.LS = Channel[7];
:=:=
:=:=//frequency.LS = 0x0000;
:=:=
:=:=// frequency.LS = -100;
:=:=
:=-----------------------------------------------------
:=Are you trying to put these three lines above main() ?
:=That will cause the error. They must be within main()
:=or some other function.

Aargh. Well spotted. I automatically inserted the lines into a function when I tested...
This does 'tally' with a lot of comments made that the syntax checker of the CCS C, is one of the weaknesses. However that having been said, many older C compilers would give completely misleading error messages too.

Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 14207
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group