Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
#include <stdio.h> /* Platform detection */ #if defined(_WIN32) || defined(_WIN64) #define PLATFORM "Windows" #define PATH_SEP '\\' #elif defined(__APPLE__) #define PLATFORM "macOS" #define PATH_SEP '/' #elif defined(__linux__) #define PLATFORM "Linux" #define PATH_SEP '/' #else #define PLATFORM "Unknown" #define PATH_SEP '/' #endif /* Build configuration */ #ifdef DEBUG #define LOG(fmt, ...) \ fprintf(stderr, "[DEBUG %s:%d] " fmt " ", \ __FILE__, __LINE__, ##__VA_ARGS__) #else #define LOG(fmt, ...) /* no-op in release builds */ #endif /* Version guard */ #define MY_VERSION 3 #if MY_VERSION < 2 #error "Version 2 or higher is required" #endif /* C/C++ compatible header */ #ifdef __cplusplus extern "C" { #endif void library_function(void); #ifdef __cplusplus } #endif void library_function(void) { printf("library_function called on %s ", PLATFORM); } int main(void) { printf("Platform: %s ", PLATFORM); printf("Path sep: '%c' ", PATH_SEP); printf("Version: %d ", MY_VERSION); LOG("main started, version=%d", MY_VERSION); library_function(); /* Compile with -DDEBUG to see LOG output */ printf("Compile with -DDEBUG to enable debug logging. "); return 0; }
Result
Open