1 #ifndef PETSC_PREPROCESSOR_MACROS_H 2 #define PETSC_PREPROCESSOR_MACROS_H 3 4 #include <petscconf.h> 5 #include <petscconf_poison.h> /* for PetscDefined() error checking */ 6 7 /* ========================================================================== */ 8 /* This facilitates using the C version of PETSc from C++ and the C++ version from C. */ 9 #if defined(__cplusplus) 10 # define PETSC_FUNCTION_NAME PETSC_FUNCTION_NAME_CXX 11 #else 12 # define PETSC_FUNCTION_NAME PETSC_FUNCTION_NAME_C 13 #endif 14 15 /* ========================================================================== */ 16 /* Since PETSc manages its own extern "C" handling users should never include PETSc include 17 * files within extern "C". This will generate a compiler error if a user does put the include 18 * file within an extern "C". 19 */ 20 #if defined(__cplusplus) 21 void assert_never_put_petsc_headers_inside_an_extern_c(int); void assert_never_put_petsc_headers_inside_an_extern_c(double); 22 #endif 23 24 #if defined(__cplusplus) 25 # define PETSC_RESTRICT PETSC_CXX_RESTRICT 26 #else 27 # define PETSC_RESTRICT PETSC_C_RESTRICT 28 #endif 29 30 #if defined(__cplusplus) 31 # define PETSC_INLINE PETSC_CXX_INLINE 32 #else 33 # define PETSC_INLINE PETSC_C_INLINE 34 #endif 35 36 #define PETSC_STATIC_INLINE static PETSC_INLINE 37 38 #if defined(_WIN32) && defined(PETSC_USE_SHARED_LIBRARIES) /* For Win32 shared libraries */ 39 # define PETSC_DLLEXPORT __declspec(dllexport) 40 # define PETSC_DLLIMPORT __declspec(dllimport) 41 # define PETSC_VISIBILITY_INTERNAL 42 #elif defined(__cplusplus) && defined(PETSC_USE_VISIBILITY_CXX) 43 # define PETSC_DLLEXPORT __attribute__((visibility ("default"))) 44 # define PETSC_DLLIMPORT __attribute__((visibility ("default"))) 45 # define PETSC_VISIBILITY_INTERNAL __attribute__((visibility ("hidden"))) 46 #elif !defined(__cplusplus) && defined(PETSC_USE_VISIBILITY_C) 47 # define PETSC_DLLEXPORT __attribute__((visibility ("default"))) 48 # define PETSC_DLLIMPORT __attribute__((visibility ("default"))) 49 # define PETSC_VISIBILITY_INTERNAL __attribute__((visibility ("hidden"))) 50 #else 51 # define PETSC_DLLEXPORT 52 # define PETSC_DLLIMPORT 53 # define PETSC_VISIBILITY_INTERNAL 54 #endif 55 56 #if defined(petsc_EXPORTS) /* CMake defines this when building the shared library */ 57 # define PETSC_VISIBILITY_PUBLIC PETSC_DLLEXPORT 58 #else /* Win32 users need this to import symbols from petsc.dll */ 59 # define PETSC_VISIBILITY_PUBLIC PETSC_DLLIMPORT 60 #endif 61 62 /* Functions tagged with PETSC_EXTERN in the header files are always defined as extern "C" when 63 * compiled with C++ so they may be used from C and are always visible in the shared libraries 64 */ 65 #if defined(__cplusplus) 66 # define PETSC_EXTERN extern "C" PETSC_VISIBILITY_PUBLIC 67 # define PETSC_EXTERN_TYPEDEF extern "C" 68 # define PETSC_INTERN extern "C" PETSC_VISIBILITY_INTERNAL 69 #else 70 # define PETSC_EXTERN extern PETSC_VISIBILITY_PUBLIC 71 # define PETSC_EXTERN_TYPEDEF 72 # define PETSC_INTERN extern PETSC_VISIBILITY_INTERNAL 73 #endif 74 75 #if defined(PETSC_USE_SINGLE_LIBRARY) 76 # define PETSC_SINGLE_LIBRARY_INTERN PETSC_INTERN 77 #else 78 # define PETSC_SINGLE_LIBRARY_INTERN PETSC_EXTERN 79 #endif 80 81 /*MC 82 PetscHasAttribute - Determine whether a particular __attribute__ is supported by the compiler 83 84 Synopsis: 85 #include <petscmacros.h> 86 boolean PetscHasAttribute(name) 87 88 Input Parameter: 89 . name - The name of the attribute to test 90 91 Notes: 92 name should be identical to what you might pass to the __attribute__ declaration itself -- 93 plain, unbroken text. 94 95 As PetscHasAttribute() is wrapper over the function-like macro __has_attribute(), the exact 96 type and value returned is implementation defined. In practice however, it usually returns 97 the integer literal 1 if the attribute is supported, and integer literal 0 if the attribute 98 is not supported. 99 100 Example Usage: 101 Typical usage is using the preprocessor 102 103 .vb 104 #if PetscHasAttribute(always_inline) 105 # define MY_ALWAYS_INLINE __attribute__((always_inline)) 106 #else 107 # define MY_ALWAYS_INLINE 108 #endif 109 110 void foo(void) MY_ALWAYS_INLINE; 111 .ve 112 113 but it can also be used in regular code 114 115 .vb 116 if (PetscHasAttribute(some_attribute)) { 117 foo(); 118 } else { 119 bar(); 120 } 121 .ve 122 123 Level: intermediate 124 125 .seealso: PetscDefined(), PetscLikely(), PetscUnlikely() 126 M*/ 127 #if !defined(__has_attribute) 128 # define __has_attribute(x) 0 129 #endif 130 #define PetscHasAttribute(name) __has_attribute(name) 131 132 /*MC 133 PETSC_NULLPTR - Standard way of indicating a null value or pointer 134 135 Notes: 136 Equivalent to NULL in C source, and nullptr in C++ source. Note that for the purposes of 137 interoperability between C and C++, setting a pointer to PETSC_NULLPTR in C++ is functonially 138 equivalent to setting the same pointer to NULL in C. That is to say that the following 139 expressions are equivalent\: 140 141 .vb 142 ptr == PETSC_NULLPTR 143 ptr == NULL 144 ptr == 0 145 !ptr 146 147 ptr = PETSC_NULLPTR 148 ptr = NULL 149 ptr = 0 150 .ve 151 152 and for completeness' sake\: 153 154 .vb 155 PETSC_NULLPTR == NULL 156 .ve 157 158 Fortran Notes: 159 Not available in Fortran 160 161 Example Usage: 162 .vb 163 // may be used in place of '\0' or other such teminators in the definition of char arrays 164 const char *const MyEnumTypes[] = { 165 "foo", 166 "bar", 167 PETSC_NULLPTR 168 }; 169 170 // may be used to nullify objects 171 PetscObject obj = PETSC_NULLPTR; 172 173 // may be used in any function expecting NULL 174 PetscInfo(PETSC_NULLPTR,"Lorem Ipsum Dolor"); 175 .ve 176 177 Developer Notes: 178 PETSC_NULLPTR must be used in place of NULL in all C++ source files. Using NULL in source 179 files compiled with a C++ compiler may lead to unexpected side-effects in function overload 180 resolution and/or compiler warnings. 181 182 Level: beginner 183 184 .seealso: PETSC_CONSTEXPR, PETSC_CONSTEXPR_14, PETSC_NOEXCEPT, PETSC_NODISCARD 185 MC*/ 186 187 /*MC 188 PETSC_CONSTEXPR - C++ constexpr 189 190 Notes: 191 Equivalent to constexpr when using a C++ compiler that supports C++11. Expands to nothing 192 if the C++ compiler does not suppport C++11 or when not compiling with a C++ compiler. Note 193 that this cannot be used in cases where an empty expansion would result in invalid code. It 194 is safe to use this in C source files. 195 196 Fortran Notes: 197 Not available in Fortran 198 199 Example Usage: 200 .vb 201 PETSC_CONSTEXPR int factorial(int n) 202 { 203 return n <= 1 ? 1 : (n * factorial(n - 1)); 204 } 205 206 PETSC_CONSTEXPR auto foo = factorial(5); // foo = 125, deduced type of int 207 .ve 208 209 Level: beginner 210 211 .seealso: PETSC_CONSTEXPR_14, PETSC_NOEXCEPT, PETSC_NULLPTR, PETSC_NODISCARD 212 MC*/ 213 214 /*MC 215 PETSC_CONSTEXPR_14 - C++14 constexpr 216 217 Notes: 218 Equivalent to constexpr when using a C++ compiler that supports C++14. Expands to nothing 219 if the C++ compiler does not suppport C++14 or when not compiling with a C++ compiler. Note 220 that this cannot be used in cases where an empty expansion would result in invalid code. It 221 is safe to use this in C source files. 222 223 Fortran Notes: 224 Not available in Fortran 225 226 Example Usage: 227 .vb 228 PETSC_CONSTEXPR_14 int factorial(int n) 229 { 230 int r = 1; 231 232 do { 233 r *= n; 234 } while (--n); 235 return r; 236 } 237 .ve 238 239 Level: beginner 240 241 .seealso: PETSC_CONSTEXPR, PETSC_NULLPTR, PETSC_NOEXCEPT, PETSC_NODISCARD 242 MC*/ 243 244 /*MC 245 PETSC_NOEXCEPT - C++ noexcept 246 247 Notes: 248 Equivalent to noexcept when using a C++ compiler, and nothing otherwise. It is safe to use 249 this in C source files. 250 251 Fortran Notes: 252 Not available in Fortran 253 254 Example Usage: 255 .vb 256 int factorial(int n) PETSC_NOEXCEPT 257 { 258 return n <= 1 ? 1 : (n * factorial(n - 1)); 259 } 260 .ve 261 262 Level: beginner 263 264 .seealso: PETSC_NULLPTR, PETSC_CONSTEXPR, PETSC_CONSTEXPR_14, PETSC_NODISCARD 265 MC*/ 266 267 /*MC 268 PETSC_NODISCARD - Mark the return value of a function as non-discardable 269 270 Notes: 271 Hints to the compiler that the return value of a function must be captured. A diagnostic may 272 (but is not required) be emitted if the value is discarded. It is safe to use this in C 273 and C++ source files. 274 275 Fortran Notes: 276 Not available in Fortran 277 278 Example Usage: 279 .vb 280 class Foo 281 { 282 int x; 283 284 public: 285 PETSC_NODISCARD Foo(int y) : x(y) { } 286 }; 287 288 PETSC_NODISCARD int factorial(int n) 289 { 290 return n <= 1 ? 1 : (n * factorial(n - 1)); 291 } 292 293 auto x = factorial(10); // OK, capturing return value 294 factorial(10); // Warning: ignoring return value of function declared 'nodiscard' 295 296 auto f = Foo(x); // OK, capturing constructed object 297 Foo(x); // Warning: Ignoring temporary created by a constructor declared 'nodiscard' 298 .ve 299 300 Developer Notes: 301 It is highly recommended if not downright required that any PETSc routines written in C++ 302 returning a PetscErrorCode be marked PETSC_NODISCARD. Ignoring the return value of PETSc 303 routines is not supported; unhandled errors may leave PETSc in an unrecoverable state. 304 305 Level: beginner 306 307 .seealso: PETSC_NULLPTR, PETSC_CONSTEXPR, PETSC_CONSTEXPR_14, PETSC_NOEXCEPT 308 MC*/ 309 310 /* C++11 features */ 311 #if defined(__cplusplus) && defined(PETSC_HAVE_CXX_DIALECT_CXX11) 312 # define PETSC_NULLPTR nullptr 313 # define PETSC_CONSTEXPR constexpr 314 # define PETSC_NOEXCEPT noexcept 315 # define PETSC_NOEXCEPT_ARG(cond_) noexcept(cond_) 316 #else 317 # define PETSC_NULLPTR NULL 318 # define PETSC_CONSTEXPR 319 # define PETSC_NOEXCEPT 320 # define PETSC_NOEXCEPT_ARG(cond_) 321 #endif 322 323 /* C++14 features */ 324 #if defined(PETSC_HAVE_CXX_DIALECT_CXX14) 325 # define PETSC_CONSTEXPR_14 PETSC_CONSTEXPR 326 #else 327 # define PETSC_CONSTEXPR_14 328 #endif 329 330 /* C++17 features */ 331 /* We met cases that the host CXX compiler (say mpicxx) supports C++17, but nvcc does not 332 * agree, even with -ccbin mpicxx! */ 333 #if defined(__cplusplus) && defined(PETSC_HAVE_CXX_DIALECT_CXX17) && (!defined(PETSC_HAVE_CUDA) || defined(PETSC_HAVE_CUDA_DIALECT_CXX17)) 334 # define PETSC_NODISCARD [[nodiscard]] 335 #else 336 # if PetscHasAttribute(warn_unused_result) 337 # define PETSC_NODISCARD __attribute__((warn_unused_result)) 338 # else 339 # define PETSC_NODISCARD 340 # endif 341 #endif 342 343 #include <petscversion.h> 344 #define PETSC_AUTHOR_INFO " The PETSc Team\n petsc-maint@mcs.anl.gov\n https://petsc.org/\n" 345 346 /*MC 347 PetscUnlikely - Hints the compiler that the given condition is usually FALSE 348 349 Synopsis: 350 #include <petscmacros.h> 351 bool PetscUnlikely(bool cond) 352 353 Not Collective 354 355 Input Parameter: 356 . cond - Boolean expression 357 358 Notes: 359 Not available from fortran. 360 361 This returns the same truth value, it is only a hint to compilers that the result of cond is 362 unlikely to be true. 363 364 Example usage: 365 .vb 366 if (PetscUnlikely(cond)) { 367 foo(); // cold path 368 } else { 369 bar(); // hot path 370 } 371 .ve 372 373 Level: advanced 374 375 .seealso: PetscLikely(), PetscUnlikelyDebug(), CHKERRQ, PetscDefined(), PetscHasAttribute() 376 M*/ 377 378 /*MC 379 PetscLikely - Hints the compiler that the given condition is usually TRUE 380 381 Synopsis: 382 #include <petscmacros.h> 383 bool PetscLikely(bool cond) 384 385 Not Collective 386 387 Input Parameter: 388 . cond - Boolean expression 389 390 Notes: 391 Not available from fortran. 392 393 This returns the same truth value, it is only a hint to compilers that the result of cond is 394 likely to be true. 395 396 Example usage: 397 .vb 398 if (PetscLikely(cond)) { 399 foo(); // hot path 400 } else { 401 bar(); // cold path 402 } 403 .ve 404 405 Level: advanced 406 407 .seealso: PetscUnlikely(), PetscDefined(), PetscHasAttribute() 408 M*/ 409 #if defined(PETSC_HAVE_BUILTIN_EXPECT) 410 # define PetscUnlikely(cond) __builtin_expect(!!(cond),0) 411 # define PetscLikely(cond) __builtin_expect(!!(cond),1) 412 #else 413 # define PetscUnlikely(cond) (cond) 414 # define PetscLikely(cond) (cond) 415 #endif 416 417 #if defined(__GNUC__) 418 /* GCC 4.8+, Clang, Intel and other compilers compatible with GCC (-std=c++0x or above) */ 419 # define PetscUnreachable_() __builtin_unreachable() 420 #elif defined(_MSC_VER) /* MSVC */ 421 # define PetscUnreachable_() __assume(0) 422 #else /* ??? */ 423 # define PetscUnreachable_() SETERRABORT(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Code path explicitly marked as unreachable executed") 424 #endif 425 426 /*MC 427 PetscUnreachable() - Indicate to the compiler that a code-path is logically unreachable 428 429 Synopsis: 430 #include <petscmacros.h> 431 void PetscUnreachable(void) 432 433 Notes: 434 Indicates to the compiler (usually via some built-in) that a particular code path is always 435 unreachable. Behavior is undefined if this function is ever executed, the user can expect an 436 unceremonious crash. 437 438 Example usage: 439 Useful in situations such as switches over enums where not all enumeration values are 440 explicitly covered by the switch 441 442 .vb 443 typedef enum {RED, GREEN, BLUE} Color; 444 445 int foo(Color c) 446 { 447 // it is known to programmer (or checked previously) that c is either RED or GREEN 448 // but compiler may not be able to deduce this and/or emit spurious warnings 449 switch (c) { 450 case RED: 451 return bar(); 452 case GREEN: 453 return baz(); 454 default: 455 PetscUnreachable(); // program is ill-formed if executed 456 } 457 } 458 .ve 459 460 Level: advanced 461 462 .seealso: SETERRABORT(), PETSCABORT() 463 MC*/ 464 #define PetscUnreachable() PetscUnreachable_() 465 466 /*MC 467 PetscExpand - Expand macro argument 468 469 Synopsis: 470 #include <petscmacros.h> 471 <macro-expansion> PetscExpand(x) 472 473 Input Paramter: 474 . x - The preprocessor token to expand 475 476 .seealso: PetscStringize(), PetscConcat() 477 MC*/ 478 #define PetscExpand(x) x 479 480 /*MC 481 PetscStringize - Stringize a token 482 483 Synopsis: 484 #include <petscmacros.h> 485 const char* PetscStringize(x) 486 487 Input Parameter: 488 . x - The token you would like to stringize 489 490 Output Parameter: 491 . <return-value> - The string representation of x 492 493 Notes: 494 Not available from Fortran. 495 496 PetscStringize() expands x before stringizing it, if you do not wish to do so, use 497 PetscStringize_() instead. 498 499 Example Usage: 500 .vb 501 #define MY_OTHER_VAR hello there 502 #define MY_VAR MY_OTHER_VAR 503 504 PetscStringize(MY_VAR) -> "hello there" 505 PetscStringize_(MY_VAR) -> "MY_VAR" 506 507 int foo; 508 PetscStringize(foo) -> "foo" 509 PetscStringize_(foo) -> "foo" 510 .ve 511 512 Level: beginner 513 514 .seealso: PetscConcat(), PetscExpandToNothing(), PetscExpand() 515 MC*/ 516 #define PetscStringize_(x) #x 517 #define PetscStringize(x) PetscStringize_(x) 518 519 /*MC 520 PetscConcat - Concatenate two tokens 521 522 Synopsis: 523 #include <petscmacros.h> 524 <macro-expansion> PetscConcat(x, y) 525 526 Input Parameters: 527 + x - First token 528 - y - Second token 529 530 Notes: 531 Not available from Fortran. 532 533 PetscConcat() will expand both arguments before pasting them together, use PetscConcat_() 534 if you don't want to expand them. 535 536 Example usage: 537 .vb 538 PetscConcat(hello,there) -> hellothere 539 540 #define HELLO hello 541 PetscConcat(HELLO,there) -> hellothere 542 PetscConcat_(HELLO,there) -> HELLOthere 543 .ve 544 545 Level: beginner 546 547 .seealso: PetscStringize(), PetscExpand() 548 MC*/ 549 #define PetscConcat_(x,y) x ## y 550 #define PetscConcat(x,y) PetscConcat_(x,y) 551 552 #define PETSC_INTERNAL_COMPL_0 1 553 #define PETSC_INTERNAL_COMPL_1 0 554 555 /*MC 556 PetscCompl - Expands to the integer complement of its argument 557 558 Synopsis: 559 #include <petscmacros.h> 560 int PetscCompl(b) 561 562 Input Parameter: 563 . b - Preprocessor variable, must expand to either integer literal 0 or 1 564 565 Output Paramter: 566 . <return-value> - Either integer literal 0 or 1 567 568 Notes: 569 Not available from Fortran. 570 571 Expands to integer literal 0 if b expands to 1, or integer literal 1 if b expands to 572 0. Behaviour is undefined if b expands to anything else. PetscCompl() will expand its 573 argument before returning the complement. 574 575 This macro can be useful for negating PetscDefined() inside macros e.g. 576 577 $ #define PETSC_DONT_HAVE_FOO PetscCompl(PetscDefined(HAVE_FOO)) 578 579 Example usage: 580 .vb 581 #define MY_VAR 1 582 PetscCompl(MY_VAR) -> 0 583 584 #undef MY_VAR 585 #define MY_VAR 0 586 PetscCompl(MY_VAR) -> 1 587 .ve 588 589 Level: beginner 590 591 .seealso: PetscConcat(), PetscDefined() 592 MC*/ 593 #define PetscCompl(b) PetscConcat_(PETSC_INTERNAL_COMPL_,PetscExpand(b)) 594 595 #if !defined(PETSC_SKIP_VARIADIC_MACROS) 596 /*MC 597 PetscDefined - Determine whether a boolean macro is defined 598 599 Synopsis: 600 #include <petscmacros.h> 601 int PetscDefined(def) 602 603 Input Parameter: 604 . def - PETSc-style preprocessor variable (without PETSC_ prepended!) 605 606 Outut Parameter: 607 . <return-value> - Either integer literal 0 or 1 608 609 Notes: 610 Not available from Fortran, requires variadic macro support, definition is disabled by 611 defining PETSC_SKIP_VARIADIC_MACROS. 612 613 PetscDefined() returns 1 if and only if "PETSC_ ## def" is defined (but empty) or defined to 614 integer literal 1. In all other cases, PetscDefined() returns integer literal 0. Therefore 615 this macro should not be used if its argument may be defined to a non-empty value other than 616 1. 617 618 The prefix "PETSC_" is automatically prepended to def. To avoid prepending "PETSC_", say to 619 add custom checks in user code, one should use PetscDefined_(). 620 621 $ #define FooDefined(d) PetscDefined_(PetscConcat(FOO_,d)) 622 623 Developer Notes: 624 Getting something that works in C and CPP for an arg that may or may not be defined is 625 tricky. Here, if we have "#define PETSC_HAVE_BOOGER 1" we match on the placeholder define, 626 insert the "0," for arg1 and generate the triplet (0, 1, 0). Then the last step cherry picks 627 the 2nd arg (a one). When PETSC_HAVE_BOOGER is not defined, we generate a (... 1, 0) pair, 628 and when the last step cherry picks the 2nd arg, we get a zero. 629 630 Our extra expansion via PetscDefined__take_second_expand() is needed with MSVC, which has a 631 nonconforming implementation of variadic macros. 632 633 Example Usage: 634 Suppose you would like to call either "foo()" or "bar()" depending on whether PETSC_USE_DEBUG 635 is defined then 636 637 .vb 638 #if PetscDefined(USE_DEBUG) 639 foo(); 640 #else 641 bar(); 642 #endif 643 644 // or alternatively within normal code 645 if (PetscDefined(USE_DEBUG)) { 646 foo(); 647 } else { 648 bar(); 649 } 650 .ve 651 652 is equivalent to 653 654 .vb 655 #if defined(PETSC_USE_DEBUG) 656 # if MY_DETECT_EMPTY_MACRO(PETSC_USE_DEBUG) // assuming you have such a macro 657 foo(); 658 # elif PETSC_USE_DEBUG == 1 659 foo(); 660 # else 661 bar(); 662 # endif 663 #else 664 bar(); 665 #endif 666 .ve 667 668 Level: intermediate 669 670 .seealso: PetscHasAttribute(), PetscUnlikely(), PetscLikely(), PetscConcat(), 671 PetscExpandToNothing(), PetscCompl() 672 MC*/ 673 #define PetscDefined_arg_1 shift, 674 #define PetscDefined_arg_ shift, 675 #define PetscDefined__take_second_expanded(ignored, val, ...) val 676 #define PetscDefined__take_second_expand(args) PetscDefined__take_second_expanded args 677 #define PetscDefined__take_second(...) PetscDefined__take_second_expand((__VA_ARGS__)) 678 #define PetscDefined__(arg1_or_junk) PetscDefined__take_second(arg1_or_junk 1, 0, at_) 679 #define PetscDefined_(value) PetscDefined__(PetscConcat_(PetscDefined_arg_,value)) 680 #define PetscDefined(def) PetscDefined_(PetscConcat(PETSC_,def)) 681 682 /*MC 683 PetscUnlikelyDebug - Hints the compiler that the given condition is usually FALSE, eliding 684 the check in optimized mode 685 686 Synopsis: 687 #include <petscmacros.h> 688 bool PetscUnlikelyDebug(bool cond) 689 690 Not Collective 691 692 Input Parameters: 693 . cond - Boolean expression 694 695 Notes: 696 Not available from Fortran, requires variadic macro support, definition is disabled by 697 defining PETSC_SKIP_VARIADIC_MACROS. 698 699 This returns the same truth value, it is only a hint to compilers that the result of cond is 700 likely to be false. When PETSc is compiled in optimized mode this will always return 701 false. Additionally, cond is guaranteed to not be evaluated when PETSc is compiled in 702 optimized mode. 703 704 Example usage: 705 This routine is shorthand for checking both the condition and whether PetscDefined(USE_DEBUG) 706 is true. So 707 708 .vb 709 if (PetscUnlikelyDebug(cond)) { 710 foo(); 711 } else { 712 bar(); 713 } 714 .ve 715 716 is equivalent to 717 718 .vb 719 if (PetscDefined(USE_DEBUG)) { 720 if (PetscUnlikely(cond)) { 721 foo(); 722 } else { 723 bar(); 724 } 725 } else { 726 bar(); 727 } 728 .ve 729 730 Level: advanced 731 732 .seealso: PetscUnlikely(), PetscLikely(), CHKERRQ, SETERRQ 733 M*/ 734 #define PetscUnlikelyDebug(cond) (PetscDefined(USE_DEBUG) && PetscUnlikely(cond)) 735 736 /*MC 737 PetscExpandToNothing - Expands to absolutely nothing at all 738 739 Synopsis: 740 #include <petscmacros.h> 741 void PetscExpandToNothing(...) 742 743 Input Parameter: 744 . __VA_ARGS__ - Anything at all 745 746 Notes: 747 Not available from Fortran, requires variadic macro support, definition is disabled by 748 defining PETSC_SKIP_VARIADIC_MACROS. 749 750 Must have at least 1 parameter. 751 752 Example usage: 753 .vb 754 PetscExpandToNothing(a,b,c) -> *nothing* 755 .ve 756 757 Level: beginner 758 759 .seealso: PetscConcat(), PetscDefined(), PetscStringize(), PetscExpand() 760 MC*/ 761 #define PetscExpandToNothing(...) 762 #endif /* !PETSC_SKIP_VARIADIC_MACROS */ 763 764 #endif /* PETSC_PREPROCESSOR_MACROS_H */ 765