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 CCS Technical Support

Expecting ; (but it shouldn't be)

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



Joined: 24 Nov 2021
Posts: 5

View user's profile Send private message

Expecting ; (but it shouldn't be)
PostPosted: Thu Dec 16, 2021 1:53 pm     Reply with quote

I'm using version 5.075 of the PCH compiler and compiling a piece of 3rd party code. I am getting the following error with the code below (I expanded out the macros to show exactly what the code is). The same macros are used elsewhere in the code with no problem. Does anyone have any ideas what might be causing this error? Thank you.

*** Error 76 "..\..\..\CMock\src\cmock.c" Line 111(81,82): Expect ;

Code:
*(uint16*)((uint16)next - (uint16)(uint16)((sizeof(uint16) > (uint16)(1u << 1)) ? sizeof(uint16) : (uint16)(1u << 1))) = (uint16)((uint16)obj - (uint16)CMock_Guts_Buffer);
jeremiah



Joined: 20 Jul 2010
Posts: 1355

View user's profile Send private message

PostPosted: Thu Dec 16, 2021 5:43 pm     Reply with quote

It appears to be invalid C code. You have:

expr ? expr : expr = expr;

Which isn't valid C as you can't have

expr = expr;

It has to be

var = expr;

The error is telling you that it didn't expect the "= expr" at the end, it expected a semicolon (since you used the ternary operator for the IF).

Specifically with the code you supplied, it [correctly] expects:
expr ? expr : expr ; // <== semicolon here
temtronic



Joined: 01 Jul 2010
Posts: 9244
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Dec 17, 2021 6:46 am     Reply with quote

My head and eyes hurt from trying to understand what that line of code really does..... Sad

though I was thinking there might be a 'typo' as he said it worked(compiled ?) at other locations within the program.
enovak



Joined: 24 Nov 2021
Posts: 5

View user's profile Send private message

PostPosted: Fri Dec 17, 2021 7:03 am     Reply with quote

I agree that this has made my head hurt as well. I had to expand out the macros just to get an idea of what is going on. What's interesting is that I'm able to get this to compile if instead of evaluating a condition in the first part of the conditional statement I instead just make this 1. That pushed me to believe there was something with that part of the conditional, but as I stated earlier this same code compiles correctly in other locations of the code.
jeremiah



Joined: 20 Jul 2010
Posts: 1355

View user's profile Send private message

PostPosted: Fri Dec 17, 2021 12:58 pm     Reply with quote

It shouldn't compile anywhere as you cannot have expr = expr in C. It could be that we are missing context of the rest of your code, but the blurb as posted shouldn't compile. Normally we ask for a "minimally compilable example", which should be easy to generate for this line of code.

It could also be that when you call this macro elsewhere that it replaces some of the code above with code that correctly compiles. Can't really tell without a working example though.
enovak



Joined: 24 Nov 2021
Posts: 5

View user's profile Send private message

PostPosted: Fri Dec 17, 2021 2:38 pm     Reply with quote

In my testing of this I was able to get the following to compile.

Code:
*(uint16*)((uint16)next - (uint16)(uint16)((1) ? sizeof(uint16) : (uint16)(1u << 1))) = (uint16)((uint16)obj - (uint16)CMock_Guts_Buffer);


I replaced the
Code:
sizeof(uint16) > (uint16)(1u << 1)
with 1 so that the conditional check was always TRUE and this worked.
jeremiah



Joined: 20 Jul 2010
Posts: 1355

View user's profile Send private message

PostPosted: Fri Dec 17, 2021 4:31 pm     Reply with quote

Ok, I see what you are doing. Converting raw numbers to pointers and de-referencing it, which makes it viable C, since that makes the expr into a temporary var. Sorry about that. The code is incredibly hard to read.

Best you can probably do is send an email to CCS support (or call them if you don't like email) if you think you have found a bug.

There's parsing bugs in v5.105 (I've confirmed 2 with CCS support), but I don't know about 5.075
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