C Code Porting Pointer Errors

Technical questions regarding the XTC tools and programming with XMOS.
Post Reply
RitchRock
XCore Addict
Posts: 186
Joined: Tue Jan 17, 2017 9:25 pm

C Code Porting Pointer Errors

Post by RitchRock »

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
Respected Member
Posts: 360
Joined: Wed May 31, 2017 6:55 pm

Post by CousinItt »

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

Post by RitchRock »

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
Respected Member
Posts: 360
Joined: Wed May 31, 2017 6:55 pm

Post by CousinItt »

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