Guards and Guarded

Technical questions regarding the xTIMEcomposer, xSOFTip Explorer and Programming with XMOS.
User avatar
XCore Legend
Posts: 1274
Joined: Thu Dec 10, 2009 10:20 pm

Guards and Guarded

Postby Folknology » Fri Jun 06, 2014 12:58 pm

I have some questions about these attributes

Code: Select all


There is a brief mention of 'guarded' here but it doesn't provide a clearly documented example, I would like to understand all of the cases where this is required.

The 'independent_guard' was discovered when I added a state guard as part of a server task interface implementation like :

Code: Select all

select {
  case (state == READY) => display_if.refresh_display():

In this case because I had not added a guarded attribute to the refresh_display to definition of the display interface.

Code: Select all

../src/rgb-matrix-xcore.xc: In function `display_server':
../src/rgb-matrix-xcore.xc:73: error: select case on has guard without [[independent_guard]] case attribute or [[guarded]] interface function attribute
xmake[1]: *** [.build_Release/src/rgb-matrix-xcore.xc.o] Error 1
xmake: *** [bin/Release/rgb-matrix-xcore.xe] Error 2

This also makes me wonder why we need to add the Guard attribute, as the compiler clearly detects the requirement itself. Are there exceptions or corner cases where this isn't so? could an example be provided to explain these choices and best uses etc..

I would love for some light to be shone on these attributes and their correct use.

P.S. I rephrased and moved this question from the startkit thread as figured it was worthy of it's own.

Posts: 11
Joined: Thu Oct 06, 2016 4:58 am

Postby gcore » Tue Jul 03, 2018 6:38 am

I too would like to understand what [[independent_guard]] does. Could anyone from XMOS provide some documentation on the keyword and its intended use case?
Posts: 11
Joined: Thu Oct 06, 2016 4:58 am

Postby gcore » Thu Jul 12, 2018 11:43 pm

I’ve had an answer from XMOS.

The [[independent_guard]] attribute actually has no effect on the execution of the code, but allows the compiler to spot a potential situation where you have added a guarded statement when you don’t intend to. There is a recommendation that it is removed in future releases of the tools.

Who is online

Users browsing this forum: No registered users and 28 guests