Base Definitions
Overview
This section describes base global definitions of Jancy C API. Moreā¦
#include <jnc_Def.h> // typedefs typedef int bool_t; typedef unsigned int uint_t; typedef unsigned char uchar_t; typedef unsigned short ushort_t; typedef unsigned long ulong_t; typedef uint8_t byte_t; typedef uint16_t word_t; typedef uint32_t dword_t; typedef uint64_t qword_t; // structs struct jnc_Guid; struct jnc_ListLink; // global functions void jnc_initialize(const char* reserved); // macros #define JNC_ASSERT #define JNC_DEFINE_GUID( \ n, \ l, \ s1, \ s2, \ b1, \ b2, \ b3, \ b4, \ b5, \ b6, \ b7, \ b8 \ ) #define JNC_EXTERN_C #define JNC_INLINE #define JNC_PTR_BITS #define JNC_PTR_SIZE #define JNC_SELECT_ANY #define _JNC_CPP_CLANG #define _JNC_CPP_GCC #define _JNC_CPP_MSC #define _JNC_CPU_AMD64 #define _JNC_CPU_X86 #define _JNC_DEBUG #define _JNC_OS_BSD #define _JNC_OS_DARWIN #define _JNC_OS_LINUX #define _JNC_OS_POSIX #define _JNC_OS_SOLARIS #define _JNC_OS_WIN #define __STDC_CONSTANT_MACROS #define __STDC_LIMIT_MACROS
Detailed Documentation
This section describes base global definitions of Jancy C API.
Typedefs
typedef int bool_t typedef unsigned int uint_t typedef unsigned char uchar_t typedef unsigned short ushort_t typedef unsigned long ulong_t typedef uint8_t byte_t typedef uint16_t word_t typedef uint32_t dword_t typedef uint64_t qword_t
Common integer type aliases in addition to the ones defined in <stdint.h>
, i.e. int8_t
, uint8_t
, int16_t
, uint16_t
, int32_t
, uint32_t
, int64_t
, uint64_t
, intptr_t
, uintptr_t
.
bool_t
aliases to int
and is used to denote boolean values.
uchar_t
and byte_t
alias to unsigned integer type with width of 8 bits.
ushort_t
and word_t
alias to unsigned integer type with width of 16 bits.
uint_t
, ulong_t
and dword_t
alias to unsigned integer type with width of 32 bits.
qword_t
aliases to unsigned integer type with width of 64 bits.
Macros
#define JNC_ASSERT
On Debug
builds, this macro causes an assertion check: it calculates the value of its argument, and if it is false
, then a corresponding message is displayed and a program is terminated.
The exact way of displaying an assertion message and its format is platform dependent, but it always includes the location of failing JNC_ASSERT
macro and the actual expression which caused it to fail.
Sample:
test_cpp: /home/user/test_cpp/main.cpp:100: int main(int, char**): Assertion `line < lineCount' failed.
On Release
builds, this macro does nothing(expands to an empty sequence).
#define JNC_DEFINE_GUID( \ n, \ l, \ s1, \ s2, \ b1, \ b2, \ b3, \ b4, \ b5, \ b6, \ b7, \ b8 \ )
A cross-platform equivalent of the Win32 DEFINE_GUID
macro.
This macro is used to define a constant holding the GUID (Globally Unique Identifier).
To generate a new GUID use any online GUID-creation tool and select the DEFINE_GUID
format; then replace DEFINE_GUID
with JNC_DEFINE_GUID
.
Sample:
// {384498AC-90AF-4634-B083-2A9B02D62680}
JNC_DEFINE_GUID(
g_testLibGuid,
0x384498ac, 0x90af, 0x4634, 0xb0, 0x83, 0x2a, 0x9b, 0x2, 0xd6, 0x26, 0x80
);
#define JNC_EXTERN_C
Set to extern "C"
if C/C++ compiler is compiling C++ code; undefined in pure C code.
#define JNC_INLINE
A compiler-independent macro used to declare an inline function.
#define JNC_PTR_SIZE
Size of data/code pointer on the current processor architecture.
JNC_PTR_SIZE
equals 4
on JNC_CPU_X86
; equals 8
on JNC_CPU_AMD64
.
JNC_PTR_BITS
equals 32
on JNC_CPU_X86
; equals 64
on JNC_CPU_AMD64
.
#define JNC_SELECT_ANY
A compiler-independent macro used to define a (variable/constant) data inside a .h
header file.
#define _JNC_CPP_MSC #define _JNC_CPP_GCC #define _JNC_CPP_CLANG
_JNC_CPP_MSC
is set to 1
if the C/C++ compiler is Microsoft Visual C/C++; undefined otherwise.
_JNC_CPP_GCC
is set to 1
if the C/C++ compiler is GCC (GNU C/C++); undefined otherwise.
_JNC_CPP_CLANG
is set to 1
if the C/C++ compiler is Clang (LLVM/Clang); undefined otherwise.
#define _JNC_CPU_X86 #define _JNC_CPU_AMD64
_JNC_CPU_X86
is set to 1
if the processor architecture is 32-bit Intel x86; undefined otherwise.
_JNC_CPU_AMD64
is set to 1
if the processor architecture is 64-bit AMD64 (x64/Intel x86_64); undefined otherwise.
#define _JNC_DEBUG
Set to 1
if the build configuration is Debug
; undefined otherwise.
#define _JNC_OS_WIN #define _JNC_OS_POSIX #define _JNC_OS_LINUX #define _JNC_OS_SOLARIS #define _JNC_OS_BSD #define _JNC_OS_DARWIN
_JNC_OS_WIN
is set to 1
if the target operating system is Microsoft Windows; undefined otherwise.
_JNC_OS_POSIX
is set to 1
if the target operating system is POSIX-compliant (Linux/Mac OS X/BSD/etc); undefined otherwise.
_JNC_OS_LINUX
is set to 1
if the target operating system is Linux; undefined otherwise. On Linux systems _JNC_OS_POSIX
is also set to 1
.
_JNC_OS_SOLARIS
is set to 1
if the target operating system is Oracle Solaris; undefined otherwise. On Solaris systems _JNC_OS_POSIX
is also set to 1
.
_JNC_OS_BSD
is set to 1
if the target operating system is BSD-family (OpenBSD/FreeBSD/Mac OS X etc); undefined otherwise. On BSD systems _JNC_OS_POSIX
is also set to 1
.
_JNC_OS_DARWIN
is set to 1
if the target operating system is Apple Darwin (Mac OS X/iOS/etc); undefined otherwise. On Darwin systems _JNC_OS_POSIX
and _JNC_OS_BSD
are also set to 1
.