Home --> Documentations --> PJLIB Reference

Build Configuration


 Building Dynamic Link Libraries (DLL/DSO)


#define PJ_DEBUG   1
#define PJ_DEBUG_MUTEX   0
#define PJ_LOG_MAX_SIZE   4000
#define PJ_LOG_INDENT_SIZE   1
#define PJ_LOG_INDENT_CHAR   '.'
#define PJ_TERM_HAS_COLOR   1
#define PJ_SAFE_POOL   0
#define PJ_POOL_DEBUG   0
#define PJ_TIMER_DEBUG   0
#define PJ_GRP_LOCK_DEBUG   0
#define PJ_HAS_IPV6   0
#define PJ_MAX_HOSTNAME   (128)
#define PJ_MAXPATH   260
#define PJ_MAX_EXCEPTION_ID   16
#define PJ_QOS_DUMMY   1
#define PJ_QOS_BSD   2
#define PJ_QOS_WM   3
#define PJ_QOS_SYMBIAN   4
#define PJ_QOS_DARWIN   5
#define PJ_HAS_SSL_SOCK   0
#define PJ_INLINE(type)   PJ_INLINE_SPECIFIER type
#define PJ_END_DECL
#define PJ_DEF_DATA(type)   type
#define PJ_IDECL(type)   PJ_DECL(type)
#define PJ_IDEF(type)   PJ_DEF(type)
#define PJ_UNUSED_ARG(arg)   (void)arg
#define PJ_TODO(id)   TODO___##id:
#define PJ_RACE_ME(x)
#define __pj_throw__(x)

Detailed Description

This section contains macros that can set during PJLIB build process to controll various aspects of the library.

Note: the values in this page does NOT necessarily reflect to the macro values during the build process.

Macro Definition Documentation

#define __pj_throw__ (   x)

Function attributes to inform that the function may throw exception.

xThe exception list, enclosed in parenthesis.

Maximum consecutive identical error for accept() operation before activesock stops calling the next ioqueue accept.

Default: 50


Mark beginning of declaration section in a header file.

#define PJ_DEBUG   1

If this macro is set to 1, it will enable some debugging checking in the library.

Default: equal to (NOT NDEBUG).

#define PJ_DEBUG_MUTEX   0

Enable this macro to activate logging to mutex/semaphore related events. This is useful to troubleshoot concurrency problems such as deadlocks. In addition, you should also add PJ_LOG_HAS_THREAD_ID flag to the log decoration to assist the troubleshooting.

Default: 0

#define PJ_DECL_NO_RETURN (   type)    PJ_NORETURN PJ_DECL(type)
typeThe return type of the function. Declare a function that will not return.
#define PJ_DEF_DATA (   type)    type
typeThe data type. Define a global data.

Enable library's extra check. If this macro is enabled, PJ_ASSERT_RETURN macro will expand to run-time checking. If this macro is disabled, PJ_ASSERT_RETURN will simply evaluate to pj_assert().

You can disable this macro to reduce size, at the risk of crashes if invalid value (e.g. NULL) is passed to the library.

Default: 1

#define PJ_END_DECL

Mark end of declaration section in a header file.


Should we use Windows Structured Exception Handling (SEH) for the PJLIB exceptions.

Default: 0


This macro declares platform/compiler specific specifier prefix to be added to symbol declaration to export the symbol when PJLIB is built as dynamic library.

This macro should have been added by platform specific headers, if the platform supports building dynamic library target.


This macro declares platform/compiler specific specifier prefix to be added to symbol definition to export the symbol when PJLIB is built as dynamic library.

This macro should have been added by platform specific headers, if the platform supports building dynamic library target.

#define PJ_EXPORT_SYMBOL (   x)

This macro has been deprecated. It will evaluate to nothing.


Determine if FD_SETSIZE is changeable/set-able. If so, then we will set it to PJ_IOQUEUE_MAX_HANDLES. Currently we detect this by checking for Winsock.


Expand functions in *_i.h header files as inline.

Default: 0.

#define PJ_GRP_LOCK_DEBUG   0

Set this to 1 to enable debugging on the group lock. Default: 0


Include error message string in the library (pj_strerror()). This is very much desirable!

Default: 1


Enable name registration for exceptions with pj_exception_id_alloc(). If this feature is enabled, then the library will keep track of names associated with each exception ID requested by application via pj_exception_id_alloc().

Disabling this macro will reduce the code and .bss size by a tad bit. See also PJ_MAX_EXCEPTION_ID.

Default: 1


Use floating point computations in the library.

Default: 1.

#define PJ_HAS_IPV6   0

Support TCP in the library. Disabling TCP will reduce the footprint slightly (about 6KB).

Default: 1 Support IPv6 in the library. If this support is disabled, some IPv6 related functions will return PJ_EIPV6NOTSUP.

Default: 0 (disabled, for now)


Do we have alternate pool implementation?

Default: 0

#define PJ_HAS_SSL_SOCK   0

Force the use of some QoS backend API for some platforms. Enable secure socket. For most platforms, this is implemented using OpenSSL, so this will require OpenSSL to be installed. For Symbian platform, this is implemented natively using CSecureSocket.

Default: 0 (for now)


Include pj_stricmp_alnum() and pj_strnicmp_alnum(), i.e. custom functions to compare alnum strings. On some systems, they're faster then stricmp/strcasecmp, but they can be slower on other systems. When disabled, pjlib will fallback to stricmp/strnicmp.

Default: 0

#define PJ_IDECL (   type)    PJ_DECL(type)
typeThe function's return type. Declare a function that may be expanded as inline.
#define PJ_IDECL_NO_RETURN (   type)    PJ_NORETURN PJ_INLINE(type)
typeThe return type of the function. Declare an inline function that will not return.
#define PJ_IDEF (   type)    PJ_DEF(type)
typeThe function's return type. Define a function that may be expanded as inline.

This macro declares platform/compiler specific specifier prefix to be added to symbol declaration to import the symbol.

This macro should have been added by platform specific headers, if the platform supports building dynamic library target.

#define PJ_INLINE (   type)    PJ_INLINE_SPECIFIER type
typeThe return type of the function. Expand the function as inline.

Default concurrency setting for sockets/handles registered to ioqueue. This controls whether the ioqueue is allowed to call the key's callback concurrently/in parallel. The default is yes, which means that if there are more than one pending operations complete simultaneously, more than one threads may call the key's callback at the same time. This generally would promote good scalability for application, at the expense of more complexity to manage the concurrent accesses.

Please see the ioqueue documentation for more info.


If PJ_IOQUEUE_HAS_SAFE_UNREG macro is defined, then ioqueue will do more things to ensure thread safety of handle unregistration operation by employing reference counter to each handle.

In addition, the ioqueue will preallocate memory for the handles, according to the maximum number of handles that is specified during ioqueue creation.

All applications would normally want this enabled, but you may disable this if:

  • there is no dynamic unregistration to all ioqueues.
  • there is no threading, or there is no preemptive multitasking.

Default: 1


When safe unregistration (PJ_IOQUEUE_HAS_SAFE_UNREG) is configured in ioqueue, the PJ_IOQUEUE_KEY_FREE_DELAY macro specifies how long the ioqueue key is kept in closing state before it can be reused.

The value is in miliseconds.

Default: 500 msec.


Constants for declaring the maximum handles that can be supported by a single IOQ framework. This constant might not be relevant to the underlying I/O queue impelementation, but still, developers should be aware of this constant, to make sure that the program will not break when the underlying implementation changes.


Overrides FD_SETSIZE so it is consistent throughout the library. We only do this if we detected that FD_SETSIZE is changeable. If FD_SETSIZE is not set-able, then PJ_IOQUEUE_MAX_HANDLES must be set to value lower than FD_SETSIZE. Specify whether pj_enum_ip_interface() function should exclude loopback interfaces.

Default: 1


Enable log indentation feature.

Default: 1

#define PJ_LOG_INDENT_CHAR   '.'

Log indentation character.

Default: space

#define PJ_LOG_INDENT_SIZE   1

Number of PJ_LOG_INDENT_CHAR to put every time pj_log_push_indent() is called.

Default: 1

#define PJ_LOG_MAX_SIZE   4000

Declare maximum logging level/verbosity. Lower number indicates higher importance, with the highest importance has level zero. The least important level is five in this implementation, but this can be extended by supplying the appropriate implementation.

The level conventions:

  • 0: fatal error
  • 1: error
  • 2: warning
  • 3: info
  • 4: debug
  • 5: trace
  • 6: more detailed trace

Default: 4 Maximum message size that can be sent to output device for each call to PJ_LOG(). If the message size is longer than this value, it will be cut. This may affect the stack usage, depending whether PJ_LOG_USE_STACK_BUFFER flag is set.

Default: 4000


Log buffer. Does the log get the buffer from the stack? (default is yes). If the value is set to NO, then the buffer will be taken from static buffer, which in this case will make the log function non-reentrant.

Default: 1

#define PJ_MAX_EXCEPTION_ID   16

Maximum number of unique exception IDs that can be requested with pj_exception_id_alloc(). For each entry, a small record will be allocated in the .bss segment.

Default: 16

#define PJ_MAX_HOSTNAME   (128)

Maximum hostname length. Libraries sometimes needs to make copy of an address to stack buffer; the value here affects the stack usage.

Default: 128

#define PJ_MAXPATH   260

Has semaphore functionality?

Default: 1 Event object (for synchronization, e.g. in Win32)

Default: 1 Maximum file name length.


Is native platform error positive number? Default: 1 (yes)


Specify if PJ_CHECK_STACK() macro is enabled to check the sanity of the stack. The OS implementation may check that no stack overflow occurs, and it also may collect statistic about stack usage. Note that this will increase the footprint of the libraries since it tracks the filename and line number of each functions.

#define PJ_POOL_DEBUG   0

If pool debugging is used, then each memory allocation from the pool will call malloc(), and pool will release all memory chunks when it is destroyed. This works better when memory verification programs such as Rational Purify is used.

Default: 0

#define PJ_QOS_BSD   2

QoS backend based on setsockopt(IP_TOS)

#define PJ_QOS_DARWIN   5

QoS backend for Darwin

#define PJ_QOS_DUMMY   1

Dummy QoS backend implementation, will always return error on all the APIs.

#define PJ_QOS_SYMBIAN   4

QoS backend for Symbian

#define PJ_QOS_WM   3

QoS backend for Windows Mobile 6

#define PJ_RACE_ME (   x)

Simulate race condition by sleeping the thread in strategic locations. Default: no!

#define PJ_SAFE_POOL   0

Set this flag to non-zero to enable various checking for pool operations. When this flag is set, assertion must be enabled in the application.

This will slow down pool creation and destruction and will add few bytes of overhead, so application would normally want to disable this feature on release build.

Default: 0


Disable WSAECONNRESET error for UDP sockets on Win32 platforms. See

Default: 1


Define the maximum number of ciphers supported by the secure socket.

Default: 256


Define the maximum number of curves supported by the secure socket.

Default: 32


Specify what should be set as the available list of SSL_CIPHERs. For example, set this as "DEFAULT" to use the default cipher list (Note: PJSIP release 2.4 and before used this "DEFAULT" setting).


#define PJ_TERM_HAS_COLOR   1

Colorfull terminal (for logging etc).

Default: 1


Specify this as stack_size argument in pj_thread_create() to specify that thread should use default stack size for the current platform.

Default: 8192

#define PJ_TIMER_DEBUG   0

Enable timer heap debugging facility. When this is enabled, application can call pj_timer_heap_dump() to show the contents of the timer heap along with the source location where the timer entries were scheduled. See for more info.

Default: 0


Should we attempt to use Pentium's rdtsc for high resolution timestamp.

Default: 0

#define PJ_TODO (   id)    TODO___##id:
idAny identifier that will be printed as TODO message. PJ_TODO macro will display TODO message as warning during compilation. Example: PJ_TODO(CLEAN_UP_ERROR);
#define PJ_UNUSED_ARG (   arg)    (void)arg
argThe argument name. PJ_UNUSED_ARG prevents warning about unused argument in a function.


PJLIB Open Source, high performance, small footprint, and very very portable framework
Copyright (C) 2006-2009 Teluu Inc.