C Code Porting Pointer Errors

Technical questions regarding the xTIMEcomposer, xSOFTip Explorer and Programming with XMOS.
RitchRock
XCore Addict
Posts: 136
Joined: Tue Jan 17, 2017 9:25 pm

C Code Porting Pointer Errors

Postby RitchRock » Fri Dec 18, 2020 8:52 pm

Hi all,

I'm porting a C codebase for a new project and am getting errors, mostly related to pointers, that I am having a difficult time dealing with.

I understand xC needs the extra annotations for memory safety, and I've done this before in other programs. Here are some examples of the problems I'm encountering:

1. In this C stack there are header files that often have something like:

Code: Select all

char *
allocate_string
(
	write_info_t * message_info,
	raw_offset_t * offset,
	const char * string
); 
Of course this will throw an error like "error: pointer return type must be marked movable, alias or unsafe". Fine, in other programs I add the annotation and move on (and I verified this with copy and pasting code into a different program). In this program when I add them I get syntax errors. Am I missing a special include somewhere to use these xC extensions?

2. Other errors are things like "pointer cast discards const qualifier" and "cannot convert non-pointer to pointer type" and "void * pointer must be declared as unsafe". Again, any attempt to rectify this with the xC annotations results in syntax errors.

What am I missing?
User avatar
CousinItt
XCore Addict
Posts: 241
Joined: Wed May 31, 2017 6:55 pm

Postby CousinItt » Sat Dec 19, 2020 7:39 pm

Are write_info_t or raw_offset_t structs? Do they contain pointers themselves?
RitchRock
XCore Addict
Posts: 136
Joined: Tue Jan 17, 2017 9:25 pm

Postby RitchRock » Sat Dec 19, 2020 10:52 pm

Not in this case. It's funny, I opened the project today and am not getting syntax errors where I was yesterday on this.
User avatar
CousinItt
XCore Addict
Posts: 241
Joined: Wed May 31, 2017 6:55 pm

Postby CousinItt » Sun Dec 20, 2020 1:07 am

Spooky. Try a clean build and see if you get the same.

Who is online

Users browsing this forum: No registered users and 7 guests