2dbi
Home/Fastly/Write a C Macro That Manipulates Pointers
FFastly·DSASWE-2Onsite – Coding (Practical)

Write a C Macro That Manipulates Pointers

Problem

Write a C macro (e.g., container_of, or a swap/offset macro) that manipulates pointers correctly, and explain the pitfalls.

Example

#define container_of(ptr, type, member) ...

Constraints

  • Avoid double-evaluation and precedence bugs

What Fastly looks for

Low-level C fluency: pointer arithmetic, macro hygiene (parenthesize args), and offsetof.

added 6 days ago
LeadersAccount