plibsys 0.0.5
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.
 
#define P_LIB_GLOBAL_API   __declspec(dllexport)
 Marks a symbol (variable, function) as global.
 
#define P_LIB_INTERNAL_API
 Marks a symbol (variable, function) as local.
 
#define P_LIB_API   P_LIB_GLOBAL_API
 Exports a symbol from a shared library.
 
#define P_NO_RETURN   __declspec(noreturn)
 Notifies a compiler that a function will never return a value (i.e.
 
#define P_LIKELY(x)
 Hints a compiler that a condition is likely to be true so it can perform code optimizations.
 
#define P_UNLIKELY(x)
 Hints a compiler that a condition is likely to be false so it can perform code optimizations.
 
#define P_UNUSED(a)
 Macro to by-pass a compiler warning on unused variables.
 
#define P_WARNING(msg)
 Prints a warning message.
 
#define P_ERROR(msg)
 Prints an error message.
 
#define P_DEBUG(msg)
 Prints a debug message.
 
#define PLIBSYS_VERSION_MAJOR
 Library major version number.
 
#define PLIBSYS_VERSION_MINOR
 Library minor version number.
 
#define PLIBSYS_VERSION_PATCH
 Library patch version number.
 
#define PLIBSYS_VERSION_STR
 Library full version in the string form, i.e.
 
#define PLIBSYS_VERSION
 Library full version in the form 0xMMNNPP (MM = major, NN = minor, PP = patch), i.e.
 
#define PLIBSYS_VERSION_CHECK(major, minor, patch)
 Makes a library version number which can be used to check the library version against which the application is compiled.
 
#define P_BEGIN_DECLS
 Starts .h file declarations to be exported as C functions.
 
#define P_END_DECLS
 Closes .h file declarations to be exported as C functions, should be always used after P_BEGIN_DECLS.
 

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)
Value:
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)
Value:
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   __declspec(dllexport)

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 113 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 114 of file pmacros.h.

◆ P_LIKELY

#define P_LIKELY ( x)
Value:
(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   __declspec(noreturn)

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 152 of file pmacros.h.

◆ P_UNLIKELY

#define P_UNLIKELY ( x)
Value:
(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)
Value:
((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)
Value:
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()

Definition at line 223 of file pmacros.h.

◆ PLIBSYS_VERSION_CHECK

#define PLIBSYS_VERSION_CHECK ( major,
minor,
patch )
Value:
((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()
...
#define PLIBSYS_VERSION_CHECK(major, minor, patch)
Makes a library version number which can be used to check the library version against which the appli...
Definition pmacros.h:279
#define PLIBSYS_VERSION
Library full version in the form 0xMMNNPP (MM = major, NN = minor, PP = patch), i....
Definition pmacros.h:223

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.

Definition at line 219 of file pmacros.h.

◆ 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.

Definition at line 220 of file pmacros.h.

◆ 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.

Definition at line 221 of file pmacros.h.

◆ 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()

Definition at line 222 of file pmacros.h.