Guest User

Untitled

a guest
Jan 19th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. possibly some code
  2. printf(some_parameters); // This should match
  3. possibly more code
  4.  
  5. #ifdef DEBUG
  6. possibly some code
  7. printf(some_parameters); // This shouldn't match
  8. possibly more code
  9. #endif
  10.  
  11. possibly some code
  12. printf(some_parameters); // This should also match
  13. possibly more code
  14.  
  15. (?<!(#ifdef [A-Γ…0-9]+)).*printf(.*);.*(?!(#endif))
  16.  
  17. $ unifdef -UDEBUG file.c | grep printf
  18. printf(some_parameters); // This should match
  19. printf(some_parameters); // This should also match
  20.  
  21. UNIFDEF(1) BSD General Commands Manual UNIFDEF(1)
  22.  
  23. NAME
  24. unifdef, unifdefall β€” remove preprocessor conditionals from code
  25.  
  26. SYNOPSIS
  27. unifdef [-ceklst] [-Ipath -Dsym[=val] -Usym -iDsym[=val] -iUsym] ... [file]
  28. unifdefall [-Ipath] ... file
  29.  
  30. DESCRIPTION
  31. The unifdef utility selectively processes conditional cpp(1) directives.
  32. It removes from a file both the directives and any additional text that
  33. they specify should be removed, while otherwise leaving the file alone.
  34.  
  35. The unifdef utility acts on #if, #ifdef, #ifndef, #elif, #else, and #endif
  36. lines, and it understands only the commonly-used subset of the expression
  37. syntax for #if and #elif lines. It handles integer values of symbols
  38. defined on the command line, the defined() operator applied to symbols
  39. defined or undefined on the command line, the operators !, <, >, <=, >=,
  40. ==, !=, &&, ||, and parenthesized expressions. Anything that it does not
  41. understand is passed through unharmed. It only processes #ifdef and
  42. #ifndef directives if the symbol is specified on the command line, other‐
  43. wise they are also passed through unchanged. By default, it ignores #if
  44. and #elif lines with constant expressions, or they may be processed by
  45. specifying the -k flag on the command line.
  46.  
  47. cpp -D<your #define options here> | grep printf
Add Comment
Please, Sign In to add comment