Advertisement
abs25

Function/Macro argument difference

Aug 15th, 2016
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.31 KB | None | 0 0
  1. The macro: #define access(ptr, offset) ((void*)((char*)ptr + (offset * size)))
  2.  
  3. The call: access(out_buffer, item_counter0 + item_counter1)
  4.  
  5. Spot the error!
  6.  
  7. The expansion: ((void*)((char*)out_buffer + (item_counter0 + item_counter1 * size)))
  8.  
  9. "(item_counter0 + item_counter1 * size)" - Operator precedence!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement