xapian-core  2.0.0
Macros
attributes.h File Reference

Compiler attribute macros. More...

+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define XAPIAN_CONST_FUNCTION
 A function which does not examine any values except its arguments and has no effects except its return value. More...
 
#define XAPIAN_PURE_FUNCTION
 Like XAPIAN_CONST_FUNCTION, but such a function can also examine global memory, perhaps via pointer or reference parameters. More...
 
#define XAPIAN_NONNULL(LIST)
 Annotate function parameters which should be non-NULL pointers. More...
 

Detailed Description

Compiler attribute macros.

Definition in file attributes.h.

Macro Definition Documentation

◆ XAPIAN_CONST_FUNCTION

#define XAPIAN_CONST_FUNCTION

A function which does not examine any values except its arguments and has no effects except its return value.

This means the compiler can perform CSE (common subexpression elimination) on calls to such a function with the same arguments, and also completely eliminate calls to this function when the return value isn't used.

Definition at line 54 of file attributes.h.

◆ XAPIAN_NONNULL

#define XAPIAN_NONNULL (   LIST)

Annotate function parameters which should be non-NULL pointers.

If LIST isn't specified, all pointer parameters will be marked in this way (which is often sufficient):

int foo(const char* p) XAPIAN_NONNULL(); int bar(char* p, const char* q) XAPIAN_NONNULL();

If there are other pointer parameters which can be NULL, then you need to specify a parenthesised list of the parameters to mark:

int foo(const char* p, int* maybenull) XAPIAN_NONNULL((1)); int bar(char* p, void* maybenull, const char* q) XAPIAN_NONNULL((1,3));

NB In a non-class function, the first parameter is numbered 1, but in a non-static class method (which isn't a constructor) then the this pointer is implicitly counted as parameter 1, though this doesn't appear to be documented. For confirmation see: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79961

Definition at line 84 of file attributes.h.

◆ XAPIAN_PURE_FUNCTION

#define XAPIAN_PURE_FUNCTION

Like XAPIAN_CONST_FUNCTION, but such a function can also examine global memory, perhaps via pointer or reference parameters.

Definition at line 59 of file attributes.h.