fork download
  1. #include <stdio.h>
  2. #include <stddef.h>
  3. #include <stdint.h>
  4.  
  5.  
  6. typedef struct {
  7. uint8_t dir; // 'F' = CW, 'R' = CCW
  8. uint32_t rev; // number of revolutions
  9. uint8_t filler[3]; // filler
  10. } stepper_data_t;
  11.  
  12. int main(void) {
  13.  
  14. printf("offset of dir: %d\n", offsetof(stepper_data_t, dir));
  15. printf("offset of rev: %d\n", offsetof(stepper_data_t, rev));
  16. printf("offset of filler: %d\n", offsetof(stepper_data_t, filler));
  17.  
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0s 5516KB
stdin
Standard input is empty
stdout
offset of dir: 0
offset of rev: 4
offset of filler: 8