X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b3b356352e87ae00a20f737c48e19b0c8413455a..0240dbaebf1aef67479ad4fffe6ec9b1548352e6:/include/xbt/swag.h diff --git a/include/xbt/swag.h b/include/xbt/swag.h index 8800b4bcb1..b153921393 100644 --- a/include/xbt/swag.h +++ b/include/xbt/swag.h @@ -171,14 +171,30 @@ static XBT_INLINE void *xbt_swag_getFirst(xbt_swag_t swag) Well, safely... Err. You can remove \a obj without having any trouble at least. */ +#ifndef __cplusplus + #define xbt_swag_foreach_safe(obj,obj_next,swag) \ for((obj)=xbt_swag_getFirst((swag)), \ ((obj)?(obj_next=xbt_swag_getNext((obj),(swag)->offset)): \ - (obj_next=NULL)); \ + (obj_next=NULL)); \ (obj)!=NULL; \ (obj)=obj_next, \ ((obj)?(obj_next=xbt_swag_getNext((obj),(swag)->offset)): \ (obj_next=NULL)) ) + +#else + +#define xbt_swag_foreach_safe(obj,obj_next,swag) \ + for((obj) = (decltype(obj)) xbt_swag_getFirst((swag)), \ + ((obj)?(obj_next = (decltype(obj)) xbt_swag_getNext((obj),(swag)->offset)): \ + (obj_next=NULL)); \ + (obj) != NULL; \ + (obj) = obj_next, \ + ((obj)?(obj_next = (decltype(obj)) xbt_swag_getNext((obj),(swag)->offset)): \ + (obj_next=NULL)) ) + +#endif + /* @} */ SG_END_DECL()