Guest User

Untitled

a guest
Apr 19th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. //*
  2. [code here]
  3. //*/
  4.  
  5. // in the following , foo() is active:
  6. /**/ foo(); /*/ bar(); /**/
  7.  
  8. // now bar() is active:
  9. /*/ foo(); /*/ bar(); /**/
  10.  
  11. #ifdef ENABLE_TESTS
  12. // code that you want to run ONLY during tests
  13. #endif
  14.  
  15. $ gcc -DENABLE_TESTS source.c
  16.  
  17. #if 0
  18. ...disabled code here
  19. #endif
  20.  
  21. //* <-- remove the first slash
  22. [code block 1]
  23. /*/
  24. [code block 2]
  25. //*/
  26.  
  27. [code block 1]
  28.  
  29. if (0)
  30. {
  31. [code block 1]
  32. }
  33. else
  34. {
  35. [code block 2]
  36. }
  37.  
  38. #if 0
  39. //code goes here
  40. #endif
  41.  
  42. bool debugging = false;
  43.  
  44. // banana banana banana
  45.  
  46. if (debugging)
  47. {
  48. // do a bunch of stuff here
  49. }
  50.  
  51. void doNothing(){}
  52. #define DO_IF(flag, code) flag ? code : doNothing();
  53.  
  54. DO_IF(collectStats, recordStats());
  55. DO_IF(collectStats, store(pullStat()));
  56.  
  57. #define DO_IF(flag,code) if( flag ) { code; }
  58.  
  59. #define COMPILE
  60.  
  61. #ifdef COMPILE
  62.  
  63. //code to comment begins
  64. cout<<"ha ha ha"<<endl;
  65. //code to comment ends
  66.  
  67. #endif
  68.  
  69. 1 ? foo() : bar();
  70.  
  71. if(isMode1)
  72. {
  73. //Code for mode1
  74. }
  75. else
  76. {
  77. //Code for other modes
  78. }
  79.  
  80. #define CRAZY_EXPERIMENT
  81.  
  82. #ifdef TEST
  83. #include "Test.h"
  84. #elif ANOTHER_TEST
  85. #include "AnotherTest.h"
  86. #elif CRAZY_EXPERIMENT
  87. #include "CrazyExperiment.h"
  88. #else
  89.  
  90. int main(int argc, int * argv[]){
  91. runTheProgramLikeNormal();
  92. }
  93.  
  94. #endif
  95.  
  96. #ifdef _DEBUG
  97. #define IF_DEBUG(x) if(x)
  98. #else
  99. #define IF_DEBUG(x) if(false)
  100. #endif
  101.  
  102. #include "debug.hpp"
  103.  
  104. int a,b, ... ,z;
  105.  
  106. ...
  107.  
  108. IF_DEBUG(... regular_expression_here_with_a_b_z ...) {
  109. // set of asserts
  110. assert(... a ...);
  111. assert(... b ...);
  112. ...
  113. assert(... z ...);
  114. }
  115.  
  116. IF_DEBUG(... regular_expression_here_with_a_b_z ...) {
  117. // set of asserts
  118. assert(... a ...);
  119. assert(... b ...);
  120. ...
  121. assert(... z ...);
  122. }
  123. else {
  124. (void)a;
  125. (void)b;
  126. ....
  127. (void)z;
  128. }
Add Comment
Please, Sign In to add comment