plibsys
pmacros.h File Reference

Miscellaneous macros. More...

#include <pmacroscompiler.h>
#include <pmacroscpu.h>
#include <pmacrosos.h>
#include <stdio.h>
Include dependency graph for pmacros.h:
This graph shows which files directly or indirectly include this file:

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

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

## ◆ P_BEGIN_DECLS

 #define P_BEGIN_DECLS

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

Since
0.0.1

## ◆ P_DEBUG

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

Prints a debug message.

Parameters
 msg Message to print.
Since
0.0.1

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

## ◆ P_ERROR

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

Prints an error message.

Parameters
 msg Message to print.
Since
0.0.1

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

## ◆ P_LIB_API

 #define P_LIB_API   P_LIB_GLOBAL_API

Exports a symbol from a shared library.

Since
0.0.1

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

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

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

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

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

## ◆ P_UNUSED

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

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

Since
0.0.1

## ◆ P_WARNING

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

Prints a warning message.

Parameters
 msg Message to print.
Since
0.0.1

## ◆ 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
 major Major version number to check. minor Minor version number to check. patch Minor version number to check.
Since
0.0.1