ntohs.c 574 B

123456789101112131415161718192021222324252627282930313233
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. int b=0;
  4. int c=0;
  5. char flag = 0;
  6. #define PASS_A(a) flag & 0x01 ? c : (flag |= 0x01, c = ntohs(a))
  7. int dosomething(int a) {
  8. return a;
  9. }
  10. int main() {
  11. int i = 0;
  12. int a = 1234;
  13. //for (i = 0; i < 100000000L; i++) {
  14. for (i = 0; i < 10; i++) {
  15. printf("PRE : a %d b %d c %d, flag %s\n", a,b,c, flag & 0x01 ? "SET":"NOT SET");
  16. a = dosomething(PASS_A(a));
  17. printf("POST: a %d b %d c %d, flag %s\n", a,b,c, flag & 0x01 ? "SET":"NOT SET");
  18. // a = ntohs(a);
  19. }
  20. exit(0);
  21. }