-
Notifications
You must be signed in to change notification settings - Fork 130
02f Areg SDK Preprocessor Definitions Reference
This guide provides a comprehensive reference for preprocessor definitions used in Areg SDK projects, detailing each definition's purpose and usage for configuring and compiling applications.
- Quick Reference
- Platform Defines
- Build Type Defines
- Areg Framework Library Defines
- Areg Logger Library Defines
- Feature Defines
- Common Use Cases
| Define | Category | Purpose | Auto-Set |
|---|---|---|---|
| POSIX | Platform | Enable POSIX API compilation | ✅ Yes |
| WINDOWS | Platform | Enable Windows API compilation | ✅ Yes |
| DEBUG | Build Type | Enable Debug build | ✅ Yes |
| NDEBUG | Build Type | Enable Release build | ✅ Yes |
| EXP_AREG_DLL | Export | Export areg shared library symbols | ✅ Yes |
| EXP_AREG_LIB | Export | Export areg static library symbols | ✅ Yes |
| IMP_AREG_DLL | Import | Import from areg shared library | ✅ Yes* |
| IMP_AREG_LIB | Import | Import from areg static library | ✅ Yes* |
| EXP_LOGGER_DLL | Export | Export areglogger shared library | ✅ Yes |
| EXP_LOGGER_LIB | Export | Export areglogger static library | ✅ Yes |
| IMP_LOGGER_DLL | Import | Import from areglogger shared library | ❌ Manual |
| IMP_LOGGER_LIB | Import | Import from areglogger static library | ❌ Manual |
| AREG_EXTENDED | Feature | Enable extended library features | ⚙️ Configurable |
| AREG_LOGS | Feature | Enable logging infrastructure | ⚙️ Configurable |
| BIT32 | Bitness | Enable 32-bit compilation | ✅ Yes |
| BIT64 | Bitness | Enable 64-bit compilation | ✅ Yes |
*Auto-set when using Areg CMake functions; manual otherwise
Preprocessor definitions can be set in:
-
CMake - Command line or
CMakeLists.txt -
Visual Studio -
msvc_setup.propsproperty file - Manual - Project-specific preprocessor definitions
These define groups are mutually exclusive (only one can be set):
-
Platform:
POSIX↔WINDOWS -
Build Type:
DEBUG↔NDEBUG -
Areg Export:
EXP_AREG_DLL↔EXP_AREG_LIB -
Areg Import:
IMP_AREG_DLL↔IMP_AREG_LIB -
Logger Export:
EXP_LOGGER_DLL↔EXP_LOGGER_LIB -
Logger Import:
IMP_LOGGER_DLL↔IMP_LOGGER_LIB -
Bitness:
BIT32↔BIT64
Purpose: Enables Areg Framework compilation with POSIX APIs.
Auto-set: Yes (when using GCC or Clang on Linux/macOS/Cygwin)
When to use:
- Building on Linux
- Building on macOS
- Building on Cygwin (Windows POSIX environment) CMake example:
cmake -B ./build -DAREG_COMPILER_FAMILY=gnuCompilers:
- GCC (
g++) - Clang (
clang++) - Cygwin GCC
Mutual exclusivity: Cannot be used with WINDOWS
Purpose: Enables Areg Framework compilation with Windows APIs.
Auto-set: Yes (when using MSVC or Clang for Windows)
When to use:
- Building on Windows with Visual Studio
- Building with MSVC compiler
- Building with Clang for Windows (
clang-cl) CMake example:
cmake -B ./build -DAREG_COMPILER_FAMILY=msvcVisual Studio: Automatically set when building with Visual Studio.
Compilers:
- MSVC (
cl) - Clang for Windows (
clang-cl)
Mutual exclusivity: Cannot be used with POSIX
Purpose: Enables Debug build configuration with debugging symbols and no optimization.
Auto-set: Yes (when CMAKE_BUILD_TYPE=Debug or Visual Studio Debug configuration)
When to use:
- Development and debugging
- Testing and diagnostics
- Analyzing issues CMake example:
cmake -B ./build -DAREG_BUILD_TYPE=Debug
# or
cmake -B ./build -DCMAKE_BUILD_TYPE=DebugVisual Studio: Select Debug configuration from toolbar.
Impact:
- Debugging symbols included
- No optimization
- Assertions enabled
- Larger binary size
Mutual exclusivity: Cannot be used with NDEBUG
Purpose: Enables Release build configuration with optimization and no debugging symbols.
Auto-set: Yes (when CMAKE_BUILD_TYPE=Release or Visual Studio Release configuration)
When to use:
- Production deployment
- Performance testing
- Final binary distribution CMake example:
cmake -B ./build -DAREG_BUILD_TYPE=Release
# or
cmake -B ./build -DCMAKE_BUILD_TYPE=ReleaseVisual Studio: Select Release configuration from toolbar.
Impact:
- No debugging symbols
- Full optimization
- Assertions disabled
- Smaller, faster binary
Mutual exclusivity: Cannot be used with DEBUG
Purpose: Exports symbols when building areg as a shared library (DLL/SO).
Auto-set: Yes (when building areg library as shared)
When to use:
- Building areg shared library
- Creating dynamic library
CMake example:
cmake -B ./build -DAREG_BINARY=sharedVisual Studio: Default configuration for areg library.
Mutual exclusivity: Cannot be used with EXP_AREG_LIB
Note
This define is only relevant when building the areg library itself, not when using it in applications.
Purpose: Exports symbols when building areg as a static library.
Auto-set: Yes (when building areg library as static)
When to use:
- Building areg static library
- Creating standalone library
CMake example:
cmake -B ./build -DAREG_BINARY=staticVisual Studio: Manually set in areg project properties.
Mutual exclusivity: Cannot be used with EXP_AREG_DLL
Note
This define is only relevant when building the areg library itself, not when using it in applications.
Purpose: Imports symbols from areg shared library (DLL/SO).
Auto-set: Yes when using Areg CMake functions; manual otherwise
When to use:
- Linking with areg shared library
- Importing from DLL
CMake example (auto-set):
# Using Areg CMake functions
macro_declare_executable(myapp main.cpp)CMake example (manual):
add_executable(myapp main.cpp)
target_compile_definitions(myapp PRIVATE IMP_AREG_DLL)
target_link_libraries(myapp PRIVATE areg::areg)Visual Studio:
- Project → Properties
- C/C++ → Preprocessor → Preprocessor Definitions
- Add:
IMP_AREG_DLL
Mutual exclusivity: Cannot be used with IMP_AREG_LIB
Important
Must match how areg library was built (shared vs static).
Purpose: Imports symbols from areg static library.
Auto-set: Yes when using Areg CMake functions; manual otherwise
When to use:
- Linking with areg static library
- Embedding areg in executable
CMake example (auto-set):
# Configure areg as static
option(AREG_BINARY "areg library type" "static")
# Using Areg CMake functions
macro_declare_executable(myapp main.cpp)CMake example (manual):
add_executable(myapp main.cpp)
target_compile_definitions(myapp PRIVATE IMP_AREG_LIB)
target_link_libraries(myapp PRIVATE areg::areg)Visual Studio:
- Project → Properties
- C/C++ → Preprocessor → Preprocessor Definitions
- Add:
IMP_AREG_LIB
Mutual exclusivity: Cannot be used with IMP_AREG_DLL
Important
Must match how areg library was built (shared vs static).
Purpose: Exports symbols when building areglogger as shared library.
Auto-set: Yes (when building areglogger library as shared)
When to use:
- Building areglogger shared library
CMake example:
cmake -B ./build -DAREG_LOGGER_BINARY=sharedVisual Studio: Default configuration for areglogger library.
Mutual exclusivity: Cannot be used with EXP_LOGGER_LIB
Note
This define is only relevant when building the areglogger library itself.
Purpose: Exports symbols when building areglogger as static library.
Auto-set: Yes (when building areglogger library as static)
When to use:
- Building areglogger static library
CMake example:
cmake -B ./build -DAREG_LOGGER_BINARY=staticVisual Studio: Manually set in areglogger project properties.
Mutual exclusivity: Cannot be used with EXP_LOGGER_DLL
Note
This define is only relevant when building the areglogger library itself.
Purpose: Imports symbols from areglogger shared library.
Auto-set: No (must be set manually)
When to use:
- Linking with areglogger shared library
- Using log observer API
CMake example:
add_executable(myapp main.cpp)
target_compile_definitions(myapp PRIVATE IMP_LOGGER_DLL)
target_link_libraries(myapp PRIVATE areglogger::areglogger)Visual Studio:
- Project → Properties
- C/C++ → Preprocessor → Preprocessor Definitions
- Add:
IMP_LOGGER_DLL
Mutual exclusivity: Cannot be used with IMP_LOGGER_LIB
Purpose: Imports symbols from areglogger static library.
Auto-set: No (must be set manually)
When to use:
- Linking with areglogger static library
- Embedding log observer in executable
CMake example:
add_executable(myapp main.cpp)
target_compile_definitions(myapp PRIVATE IMP_LOGGER_LIB)
target_link_libraries(myapp PRIVATE areglogger::areglogger)Visual Studio:
- Project → Properties
- C/C++ → Preprocessor → Preprocessor Definitions
- Add:
IMP_LOGGER_LIB
Mutual exclusivity: Cannot be used with IMP_LOGGER_DLL
Purpose: Enables additional features in aregextend library.
Auto-set: No (configurable, default is OFF)
When to use:
- Need extended utility features
- Using database functionality
- Using advanced terminal features
Dependencies:
-
Linux/Cygwin: Requires
ncurseslibrary
CMake example:
cmake -B ./build -DAREG_EXTENDED=ONVisual Studio:
Edit msvc_setup.props:
<AregExtended>1</AregExtended>Impact:
- Adds extended library features
- May require additional dependencies
- Slightly larger binary
Purpose: Enables logging infrastructure in Areg Framework.
Auto-set: No (configurable, default is ON)
When to use:
- Need application logging
- Debugging and diagnostics
- Production monitoring
CMake example:
# Enable logging (default)
cmake -B ./build -DAREG_LOGS=ON
# Disable logging
cmake -B ./build -DAREG_LOGS=OFFVisual Studio:
Edit msvc_setup.props:
<AregLogs>1</AregLogs> <!-- Enable -->
<AregLogs>0</AregLogs> <!-- Disable -->Impact:
- ON: Logging infrastructure included (larger binary)
- OFF: No logging (smaller, faster binary)
Tip
Disable logging in production for minimal overhead.
Purpose: Configures build for 32-bit systems.
Auto-set: Yes (based on compiler and platform selection)
When to use:
- Building for 32-bit systems
- Legacy system support
CMake example:
cmake -B ./build -DAREG_PROCESSOR=x86Visual Studio: Select Win32 platform.
Mutual exclusivity: Cannot be used with BIT64
Purpose: Configures build for 64-bit systems.
Auto-set: Yes (based on compiler and platform selection)
When to use:
- Building for 64-bit systems (recommended)
- Modern system deployment
CMake example:
cmake -B ./build -DAREG_PROCESSOR=x64Visual Studio: Select x64 platform.
Mutual exclusivity: Cannot be used with BIT32
Scenario: Building Windows application using areg DLL.
Required defines:
-
WINDOWS(auto-set) IMP_AREG_DLL-
DEBUGorNDEBUG(auto-set) -
BIT64orBIT32(auto-set)
CMake:
add_executable(myapp main.cpp)
target_compile_definitions(myapp PRIVATE IMP_AREG_DLL)
target_link_libraries(myapp PRIVATE areg::areg)Visual Studio:
// In source file or project preprocessor definitions
#define IMP_AREG_DLLScenario: Building Linux application with areg statically linked.
Required defines:
-
POSIX(auto-set) IMP_AREG_LIB-
DEBUGorNDEBUG(auto-set) -
BIT64orBIT32(auto-set)
CMake:
# Configure areg as static
set(AREG_BINARY "static" CACHE STRING "areg library type")
add_executable(myapp main.cpp)
target_compile_definitions(myapp PRIVATE IMP_AREG_LIB)
target_link_libraries(myapp PRIVATE areg::areg)Scenario: Production application with minimal overhead (no logging).
Required defines:
- Platform define (auto-set)
- Import define for areg
-
AREG_LOGSdisabled -
NDEBUG(Release build)
CMake:
cmake -B ./build \
-DAREG_BUILD_TYPE=Release \
-DAREG_LOGS=OFF \
-DAREG_BINARY=sharedImpact:
- Smaller binary size
- Faster execution
- No logging overhead
Scenario: Application using aregextend library features.
Required defines:
- Platform define (auto-set)
- Import define for areg
-
AREG_EXTENDEDenabled
CMake:
cmake -B ./build -DAREG_EXTENDED=ONDependencies:
- Linux/Cygwin: Install
ncurseslibrary
Impact:
- Extended features available
- Additional library dependencies
Scenario: Application building on both Windows and Linux.
Strategy: Use auto-set platform defines, manually set others.
CMakeLists.txt:
cmake_minimum_required(VERSION 3.20)
project(myapp)
# Platform-specific handling
if(WIN32)
# Windows-specific settings
set(PLATFORM_LIBS ws2_32)
elseif(UNIX)
# Linux-specific settings
set(PLATFORM_LIBS pthread)
endif()
# Application
add_executable(myapp main.cpp)
target_compile_definitions(myapp PRIVATE IMP_AREG_DLL)
target_link_libraries(myapp PRIVATE areg::areg ${PLATFORM_LIBS})Defines set:
- Windows:
WINDOWS,IMP_AREG_DLL,BIT64 - Linux:
POSIX,IMP_AREG_DLL,BIT64
Scenario: Building areg framework from source.
Export defines (auto-set):
-
EXP_AREG_DLL(shared) orEXP_AREG_LIB(static)
CMake:
# Build areg as shared library
cmake -B ./build -DAREG_BINARY=shared
# Build areg as static library
cmake -B ./build -DAREG_BINARY=staticNote
Export defines are only for building areg itself, not for applications using areg.
Configuration Guides:
- CMake Configuration Options - Complete CMake options
- CMake Integration - Using Areg in projects
- Visual Studio Integration - MSVC setup
Configuration Files:
- user.cmake - CMake configuration
- msvc_setup.props - Visual Studio properties
Build Guides:
Help: For questions, open a discussion or issue on GitHub.
Help us to make docs greater: See something is wrong, unclear or need a help? Submit a change, open a discussion or ask AREG SDK community a question.
Copyright © 2026, Aregtech, www.areg.tech, email: info[at]areg.tech