#define nb_cell_index(X) ((nb_cell_index_t)((size_t)((unsigned char *)(X) - (unsigned char *)nb_memory.objects) / sizeof(nb_cell_t)))

Although we could simply use X - memory.objects to compute the object index, but that would generate a signed division because of the way that C specifies the result of the difference of two pointers. So, we manually calculate the result which is an unsigned shift.