plibsys  0.0.4
Macros
pmacros.h File Reference

Miscellaneous macros. More...

#include <pmacroscompiler.h>
#include <pmacroscpu.h>
#include <pmacrosos.h>
#include <stdio.h>

Go to the source code of this file.

Macros

#define P_GNUC_WARN_UNUSED_RESULT
 Gives a warning if the result returned from a function is not being used. More...
 
#define P_LIB_GLOBAL_API
 Marks a symbol (variable, function) as global. More...
 
#define P_LIB_INTERNAL_API
 Marks a symbol (variable, function) as local. More...
 
#define P_LIB_API   P_LIB_GLOBAL_API
 Exports a symbol from a shared library. More...
 
#define P_NO_RETURN
 Notifies a compiler that a function will never return a value (i.e. More...
 
#define P_LIKELY(x)   (x)
 Hints a compiler that a condition is likely to be true so it can perform code optimizations. More...
 
#define P_UNLIKELY(x)   (x)
 Hints a compiler that a condition is likely to be false so it can perform code optimizations. More...
 
#define P_UNUSED(a)   ((void) a)
 Macro to by-pass a compiler warning on unused variables. More...
 
#define P_WARNING(msg)   printf ("** Warning: %s **\n", msg)
 Prints a warning message. More...
 
#define P_ERROR(msg)   printf ("** Error: %s **\n", msg)
 Prints an error message. More...
 
#define P_DEBUG(msg)   printf ("** Debug: %s **\n", msg)
 Prints a debug message. More...
 
#define PLIBSYS_VERSION_MAJOR
 Library major version number. More...
 
#define PLIBSYS_VERSION_MINOR
 Library minor version number. More...
 
#define PLIBSYS_VERSION_PATCH
 Library patch version number. More...
 
#define PLIBSYS_VERSION_STR
 Library full version in the string form, i.e. More...
 
#define PLIBSYS_VERSION
 Library full version in the form 0xMMNNPP (MM = major, NN = minor, PP = patch), i.e. More...
 
#define PLIBSYS_VERSION_CHECK(major, minor, patch)   ((major << 16) | (minor << 8) | (patch))
 Makes a library version number which can be used to check the library version against which the application is compiled. More...
 
#define P_BEGIN_DECLS
 Starts .h file declarations to be exported as C functions. More...
 
#define P_END_DECLS
 Closes .h file declarations to be exported as C functions, should be always used after P_BEGIN_DECLS. More...
 

Detailed Description

Miscellaneous macros.

Author
Alexander Saprykin

All the macros are completely independent of any other platform-specific headers, thus gurantee to work with any compiler under any operating system in the same way as they are used within the library.

This family of macros provides various additional capabilities (compiler hints, attributes, version, etc.).

Definition in file pmacros.h.

Macro Definition Documentation

◆ P_BEGIN_DECLS

#define P_BEGIN_DECLS

Starts .h file declarations to be exported as C functions.

Since
0.0.1

Definition at line 298 of file pmacros.h.

◆ P_DEBUG

#define P_DEBUG (   msg)    printf ("** Debug: %s **\n", msg)

Prints a debug message.

Parameters
msgMessage to print.
Since
0.0.1

Definition at line 216 of file pmacros.h.

◆ P_END_DECLS

#define P_END_DECLS

Closes .h file declarations to be exported as C functions, should be always used after P_BEGIN_DECLS.

Since
0.0.1

Definition at line 299 of file pmacros.h.

◆ P_ERROR

#define P_ERROR (   msg)    printf ("** Error: %s **\n", msg)

Prints an error message.

Parameters
msgMessage to print.
Since
0.0.1

Definition at line 208 of file pmacros.h.

◆ P_GNUC_WARN_UNUSED_RESULT

#define P_GNUC_WARN_UNUSED_RESULT

Gives a warning if the result returned from a function is not being used.

Since
0.0.1

Definition at line 72 of file pmacros.h.

◆ P_LIB_API

#define P_LIB_API   P_LIB_GLOBAL_API

Exports a symbol from a shared library.

Since
0.0.1

Definition at line 138 of file pmacros.h.

◆ P_LIB_GLOBAL_API

#define P_LIB_GLOBAL_API

Marks a symbol (variable, function) as global.

Since
0.0.4

Global symbols are exported during the linkage and are available from the outside of the module they are defined in. Use it for public API.

Note
Some compilers allow to put this attribute at the beginning of the symbol declaration, and some also at the end of the declaration. Thus it is better to put it in the beginning for more portability.

Definition at line 128 of file pmacros.h.

◆ P_LIB_INTERNAL_API

#define P_LIB_INTERNAL_API

Marks a symbol (variable, function) as local.

Since
0.0.4

Local symbols are not exported during the linkage and are not available from the outside of the module they are defined in. Use it for internal API.

Note
Some compilers allow to put this attribute at the beginning of the symbol declaration, and some also at the end of the declaration. Thus it is better to put it in the beginning for more portability.

Definition at line 129 of file pmacros.h.

◆ P_LIKELY

#define P_LIKELY (   x)    (x)

Hints a compiler that a condition is likely to be true so it can perform code optimizations.

Since
0.0.1

Definition at line 183 of file pmacros.h.

◆ P_NO_RETURN

#define P_NO_RETURN

Notifies a compiler that a function will never return a value (i.e.

due to the abort () call).

Since
0.0.1

Definition at line 159 of file pmacros.h.

◆ P_UNLIKELY

#define P_UNLIKELY (   x)    (x)

Hints a compiler that a condition is likely to be false so it can perform code optimizations.

Since
0.0.1

Definition at line 184 of file pmacros.h.

◆ P_UNUSED

#define P_UNUSED (   a)    ((void) a)

Macro to by-pass a compiler warning on unused variables.

Since
0.0.1

Definition at line 192 of file pmacros.h.

◆ P_WARNING

#define P_WARNING (   msg)    printf ("** Warning: %s **\n", msg)

Prints a warning message.

Parameters
msgMessage to print.
Since
0.0.1

Definition at line 200 of file pmacros.h.

◆ PLIBSYS_VERSION

#define PLIBSYS_VERSION

Library full version in the form 0xMMNNPP (MM = major, NN = minor, PP = patch), i.e.

0x000001.

Since
0.0.1
Note
This is the version against which the application is compiled.
See also
p_libsys_version()

◆ PLIBSYS_VERSION_CHECK

#define PLIBSYS_VERSION_CHECK (   major,
  minor,
  patch 
)    ((major << 16) | (minor << 8) | (patch))

Makes a library version number which can be used to check the library version against which the application is compiled.

Parameters
majorMajor version number to check.
minorMinor version number to check.
patchMinor version number to check.
Since
0.0.1
See also
p_libsys_version()

Definition at line 279 of file pmacros.h.

◆ PLIBSYS_VERSION_MAJOR

#define PLIBSYS_VERSION_MAJOR

Library major version number.

Since
0.0.1
Note
This is the version against which the application is compiled.

◆ PLIBSYS_VERSION_MINOR

#define PLIBSYS_VERSION_MINOR

Library minor version number.

Since
0.0.1
Note
This is the version against which the application is compiled.

◆ PLIBSYS_VERSION_PATCH

#define PLIBSYS_VERSION_PATCH

Library patch version number.

Since
0.0.1
Note
This is the version against which the application is compiled.

◆ PLIBSYS_VERSION_STR

#define PLIBSYS_VERSION_STR

Library full version in the string form, i.e.

"0.0.1".

Since
0.0.1
Note
This is the version against which the application is compiled.
See also
p_libsys_version()