xref: /petsc/include/petscmacros.h (revision e2bae4bf6c8cbd1fb91781ff4b49d88256025601)
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 /*MC
418   PetscUnreachable() - Indicate to the compiler that a code-path is logically unreachable
419 
420   Synopsis:
421   #include <petscmacros.h>
422   void PetscUnreachable(void)
423 
424   Notes:
425   Indicates to the compiler (usually via some built-in) that a particular code path is always
426   unreachable. Behavior is undefined if this function is ever executed, the user can expect an
427   unceremonious crash.
428 
429   Example usage:
430   Useful in situations such as switches over enums where not all enumeration values are
431   explicitly covered by the switch
432 
433 .vb
434   typedef enum {RED, GREEN, BLUE} Color;
435 
436   int foo(Color c)
437   {
438     // it is known to programmer (or checked previously) that c is either RED or GREEN
439     // but compiler may not be able to deduce this and/or emit spurious warnings
440     switch (c) {
441       case RED:
442         return bar();
443       case GREEN:
444         return baz();
445       default:
446         PetscUnreachable(); // program is ill-formed if executed
447     }
448   }
449 .ve
450 
451   Level: advanced
452 
453 .seealso: SETERRABORT(), PETSCABORT()
454 MC*/
455 #if defined(__GNUC__)
456 /* GCC 4.8+, Clang, Intel and other compilers compatible with GCC (-std=c++0x or above) */
457 #  define PetscUnreachable() __builtin_unreachable()
458 #elif defined(_MSC_VER) /* MSVC */
459 #  define PetscUnreachable() __assume(0)
460 #else /* ??? */
461 #  define PetscUnreachable() SETERRABORT(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Code path explicitly marked as unreachable executed")
462 #endif
463 
464 /*MC
465   PetscExpand - Expand macro argument
466 
467   Synopsis:
468   #include <petscmacros.h>
469   <macro-expansion> PetscExpand(x)
470 
471   Input Paramter:
472 . x - The preprocessor token to expand
473 
474 .seealso: PetscStringize(), PetscConcat()
475 MC*/
476 #define PetscExpand_(...) __VA_ARGS__
477 #define PetscExpand(...)  PetscExpand_(__VA_ARGS__)
478 
479 /*MC
480   PetscStringize - Stringize a token
481 
482   Synopsis:
483   #include <petscmacros.h>
484   const char* PetscStringize(x)
485 
486   Input Parameter:
487 . x - The token you would like to stringize
488 
489   Output Parameter:
490 . <return-value> - The string representation of x
491 
492   Notes:
493   Not available from Fortran.
494 
495   PetscStringize() expands x before stringizing it, if you do not wish to do so, use
496   PetscStringize_() instead.
497 
498   Example Usage:
499 .vb
500   #define MY_OTHER_VAR hello there
501   #define MY_VAR       MY_OTHER_VAR
502 
503   PetscStringize(MY_VAR)  -> "hello there"
504   PetscStringize_(MY_VAR) -> "MY_VAR"
505 
506   int foo;
507   PetscStringize(foo)  -> "foo"
508   PetscStringize_(foo) -> "foo"
509 .ve
510 
511   Level: beginner
512 
513 .seealso: PetscConcat(), PetscExpandToNothing(), PetscExpand()
514 MC*/
515 #define PetscStringize_(x) #x
516 #define PetscStringize(x)  PetscStringize_(x)
517 
518 /*MC
519   PetscConcat - Concatenate two tokens
520 
521   Synopsis:
522   #include <petscmacros.h>
523   <macro-expansion> PetscConcat(x, y)
524 
525   Input Parameters:
526 + x - First token
527 - y - Second token
528 
529   Notes:
530   Not available from Fortran.
531 
532   PetscConcat() will expand both arguments before pasting them together, use PetscConcat_()
533   if you don't want to expand them.
534 
535   Example usage:
536 .vb
537   PetscConcat(hello,there) -> hellothere
538 
539   #define HELLO hello
540   PetscConcat(HELLO,there)  -> hellothere
541   PetscConcat_(HELLO,there) -> HELLOthere
542 .ve
543 
544   Level: beginner
545 
546 .seealso: PetscStringize(), PetscExpand()
547 MC*/
548 #define PetscConcat_(x,y) x ## y
549 #define PetscConcat(x,y)  PetscConcat_(x,y)
550 
551 #define PETSC_INTERNAL_COMPL_0 1
552 #define PETSC_INTERNAL_COMPL_1 0
553 
554 /*MC
555   PetscCompl - Expands to the integer complement of its argument
556 
557   Synopsis:
558   #include <petscmacros.h>
559   int PetscCompl(b)
560 
561   Input Parameter:
562 . b - Preprocessor variable, must expand to either integer literal 0 or 1
563 
564   Output Paramter:
565 . <return-value> - Either integer literal 0 or 1
566 
567   Notes:
568   Not available from Fortran.
569 
570   Expands to integer literal 0 if b expands to 1, or integer literal 1 if b expands to
571   0. Behaviour is undefined if b expands to anything else. PetscCompl() will expand its
572   argument before returning the complement.
573 
574   This macro can be useful for negating PetscDefined() inside macros e.g.
575 
576 $ #define PETSC_DONT_HAVE_FOO PetscCompl(PetscDefined(HAVE_FOO))
577 
578   Example usage:
579 .vb
580   #define MY_VAR 1
581   PetscCompl(MY_VAR) -> 0
582 
583   #undef  MY_VAR
584   #define MY_VAR 0
585   PetscCompl(MY_VAR) -> 1
586 .ve
587 
588   Level: beginner
589 
590 .seealso: PetscConcat(), PetscDefined()
591 MC*/
592 #define PetscCompl(b) PetscConcat_(PETSC_INTERNAL_COMPL_,PetscExpand(b))
593 
594 #if !defined(PETSC_SKIP_VARIADIC_MACROS)
595 /*MC
596   PetscDefined - Determine whether a boolean macro is defined
597 
598   Synopsis:
599   #include <petscmacros.h>
600   int PetscDefined(def)
601 
602   Input Parameter:
603 . def - PETSc-style preprocessor variable (without PETSC_ prepended!)
604 
605   Outut Parameter:
606 . <return-value> - Either integer literal 0 or 1
607 
608   Notes:
609   Not available from Fortran, requires variadic macro support, definition is disabled by
610   defining PETSC_SKIP_VARIADIC_MACROS.
611 
612   PetscDefined() returns 1 if and only if "PETSC_ ## def" is defined (but empty) or defined to
613   integer literal 1. In all other cases, PetscDefined() returns integer literal 0. Therefore
614   this macro should not be used if its argument may be defined to a non-empty value other than
615   1.
616 
617   The prefix "PETSC_" is automatically prepended to def. To avoid prepending "PETSC_", say to
618   add custom checks in user code, one should use PetscDefined_().
619 
620 $ #define FooDefined(d) PetscDefined_(PetscConcat(FOO_,d))
621 
622   Developer Notes:
623   Getting something that works in C and CPP for an arg that may or may not be defined is
624   tricky. Here, if we have "#define PETSC_HAVE_BOOGER 1" we match on the placeholder define,
625   insert the "0," for arg1 and generate the triplet (0, 1, 0). Then the last step cherry picks
626   the 2nd arg (a one). When PETSC_HAVE_BOOGER is not defined, we generate a (... 1, 0) pair,
627   and when the last step cherry picks the 2nd arg, we get a zero.
628 
629   Our extra expansion via PetscDefined__take_second_expand() is needed with MSVC, which has a
630   nonconforming implementation of variadic macros.
631 
632   Example Usage:
633   Suppose you would like to call either "foo()" or "bar()" depending on whether PETSC_USE_DEBUG
634   is defined then
635 
636 .vb
637   #if PetscDefined(USE_DEBUG)
638     foo();
639   #else
640     bar();
641   #endif
642 
643   // or alternatively within normal code
644   if (PetscDefined(USE_DEBUG)) {
645     foo();
646   } else {
647     bar();
648   }
649 .ve
650 
651   is equivalent to
652 
653 .vb
654   #if defined(PETSC_USE_DEBUG)
655   #  if MY_DETECT_EMPTY_MACRO(PETSC_USE_DEBUG) // assuming you have such a macro
656        foo();
657   #   elif PETSC_USE_DEBUG == 1
658        foo();
659   #   else
660        bar();
661   #  endif
662   #else
663   bar();
664   #endif
665 .ve
666 
667   Level: intermediate
668 
669 .seealso: PetscHasAttribute(), PetscUnlikely(), PetscLikely(), PetscConcat(),
670 PetscExpandToNothing(), PetscCompl()
671 MC*/
672 #define PetscDefined_arg_1 shift,
673 #define PetscDefined_arg_  shift,
674 #define PetscDefined__take_second_expanded(ignored, val, ...) val
675 #define PetscDefined__take_second_expand(args) PetscDefined__take_second_expanded args
676 #define PetscDefined__take_second(...) PetscDefined__take_second_expand((__VA_ARGS__))
677 #define PetscDefined__(arg1_or_junk)   PetscDefined__take_second(arg1_or_junk 1, 0, at_)
678 #define PetscDefined_(value)           PetscDefined__(PetscConcat_(PetscDefined_arg_,value))
679 #define PetscDefined(def)              PetscDefined_(PetscConcat(PETSC_,def))
680 
681 /*MC
682   PetscUnlikelyDebug - Hints the compiler that the given condition is usually FALSE, eliding
683   the check in optimized mode
684 
685   Synopsis:
686   #include <petscmacros.h>
687   bool PetscUnlikelyDebug(bool cond)
688 
689   Not Collective
690 
691   Input Parameters:
692 . cond - Boolean expression
693 
694   Notes:
695   Not available from Fortran, requires variadic macro support, definition is disabled by
696   defining PETSC_SKIP_VARIADIC_MACROS.
697 
698   This returns the same truth value, it is only a hint to compilers that the result of cond is
699   likely to be false. When PETSc is compiled in optimized mode this will always return
700   false. Additionally, cond is guaranteed to not be evaluated when PETSc is compiled in
701   optimized mode.
702 
703   Example usage:
704   This routine is shorthand for checking both the condition and whether PetscDefined(USE_DEBUG)
705   is true. So
706 
707 .vb
708   if (PetscUnlikelyDebug(cond)) {
709     foo();
710   } else {
711     bar();
712   }
713 .ve
714 
715   is equivalent to
716 
717 .vb
718   if (PetscDefined(USE_DEBUG)) {
719     if (PetscUnlikely(cond)) {
720       foo();
721     } else {
722       bar();
723     }
724   } else {
725     bar();
726   }
727 .ve
728 
729   Level: advanced
730 
731 .seealso: PetscUnlikely(), PetscLikely(), CHKERRQ, SETERRQ
732 M*/
733 #define PetscUnlikelyDebug(cond) (PetscDefined(USE_DEBUG) && PetscUnlikely(cond))
734 
735 /*MC
736   PetscExpandToNothing - Expands to absolutely nothing at all
737 
738   Synopsis:
739   #include <petscmacros.h>
740   void PetscExpandToNothing(...)
741 
742   Input Parameter:
743 . __VA_ARGS__ - Anything at all
744 
745   Notes:
746   Not available from Fortran, requires variadic macro support, definition is disabled by
747   defining PETSC_SKIP_VARIADIC_MACROS.
748 
749   Must have at least 1 parameter.
750 
751   Example usage:
752 .vb
753   PetscExpandToNothing(a,b,c) -> *nothing*
754 .ve
755 
756   Level: beginner
757 
758 .seealso: PetscConcat(), PetscDefined(), PetscStringize(), PetscExpand()
759 MC*/
760 #define PetscExpandToNothing(...)
761 #endif /* !PETSC_SKIP_VARIADIC_MACROS */
762 
763 #endif /* PETSC_PREPROCESSOR_MACROS_H */
764