fork(1) download
  1. #include <stdio.h>
  2.  
  3. // from header 1
  4. #pragma pack(push)
  5. #pragma pack(1)
  6. struct my_internal_buisiless {
  7. int cool_story;
  8. char magic;
  9. int another_cool_story;
  10. };
  11. #pragma pack(pop)
  12.  
  13. // from header 2
  14. #pragma pack(push)
  15. #pragma pack(2)
  16. struct not_your_buisiness {
  17. char magic[2];
  18. float flop;
  19. };
  20. #pragma pack(pop)
  21.  
  22. // from header 3
  23. struct widget {
  24. int blahblah;
  25. struct my_internal_buisiless business[4];
  26. struct not_your_buisiness nope[4];
  27. };
  28.  
  29.  
  30. struct struct1 {
  31. int element0;
  32. struct {
  33. int element0;
  34. char element1;
  35. int element2;
  36. } element1[4];
  37. struct {
  38. char element0[2];
  39. float element1;
  40. } element2[4];
  41. };
  42.  
  43. void my_migthy_call(struct widget *data_for_result)
  44. {
  45. data_for_result->nope[3].flop = 100.99;
  46. }
  47.  
  48. int main(int argc, char* argv[])
  49. {
  50. struct widget my_test;
  51. struct struct1 shit_test;
  52. my_migthy_call(&my_test);
  53. my_migthy_call(&shit_test);
  54. printf("My result: %f\n", my_test.nope[3].flop);
  55. printf("Shit result result: %f\n", shit_test.element2[3].element1);
  56. }
Success #stdin #stdout 0s 9424KB
stdin
Standard input is empty
stdout
My result: 100.989998
Shit result result: 0.000000