{"id":21730452,"url":"https://github.com/kumarjitdas/kdapi","last_synced_at":"2025-07-10T20:39:07.966Z","repository":{"id":246666817,"uuid":"821654984","full_name":"KumarjitDas/kdapi","owner":"KumarjitDas","description":"A simple, header-only C library designed to provide compile-time system information.","archived":false,"fork":false,"pushed_at":"2024-07-07T19:20:35.000Z","size":81,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-20T23:26:38.412Z","etag":null,"topics":["c90","clion","cmake","gcc","gnu-linux","visual-studio","windows"],"latest_commit_sha":null,"homepage":"","language":"CMake","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KumarjitDas.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-29T04:24:07.000Z","updated_at":"2024-07-07T19:20:38.000Z","dependencies_parsed_at":"2024-07-07T20:43:03.862Z","dependency_job_id":null,"html_url":"https://github.com/KumarjitDas/kdapi","commit_stats":null,"previous_names":["kumarjitdas/kdapi"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/KumarjitDas/kdapi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KumarjitDas%2Fkdapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KumarjitDas%2Fkdapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KumarjitDas%2Fkdapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KumarjitDas%2Fkdapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KumarjitDas","download_url":"https://codeload.github.com/KumarjitDas/kdapi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KumarjitDas%2Fkdapi/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264653390,"owners_count":23644436,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c90","clion","cmake","gcc","gnu-linux","visual-studio","windows"],"created_at":"2024-11-26T04:16:03.891Z","updated_at":"2025-07-10T20:39:07.920Z","avatar_url":"https://github.com/KumarjitDas.png","language":"CMake","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# KDAPI\n\nKDAPI is a simple, header-only C library designed to provide compile-time system information. This project targets both Windows and GNU/Linux (32-bit and 64-bit) platforms. The library aims to help developers easily retrieve details about the compiler, target operating system, target CPU, and endianness at compile-time.\n\n## Table of Contents\n\n- [Features](#features)\n- [Requirements](#requirements)\n- [Usage](#usage)\n- [Roadmap](#roadmap)\n- [Contributing](#contributing)\n- [Naming Convention](#naming-convention)\n- [License](#license)\n- [Project Status](#project-status)\n- [Contact](#contact)\n- [Versioning](#versioning)\n- [Changelog](#changelog)\n\n## Features\n\n- Detects compiler type and version.\n- Identifies the target operating system.\n- Determines the target CPU architecture.\n- Determines the target architecture integer sizes (32 or 64 bit).\n- Determines the target architecture pointer(address) sizes (32 or 64 bit).\n- Checks system endianness.\n- Provides macros for import-export signatures, calling conventions, and extern indicators.\n- CMake target for ease of use with other CMake projects.\n\n## Requirements\n\nTo get started with this project, download and install the following.\n\n- Download and install **git**\n    - If you use *Windows*, then go to this [link](https://git-scm.com/downloads) and download and install the suitable version.\n    - If you use any stable version of *Debian/Ubuntu* then run this command in your terminal\n    \n        ```shell\n        sudo apt-get install git\n        ```\n\n    - If you use *macOS* then install [homebrew](https://brew.sh/) if you don't already have it, then run this command in your terminal\n    \n        ```shell\n        brew install git\n        ```\n\n- Run the command to clone this repository\n\n  ```shell\n  git clone https://github.com/KumarjitDas/kdapi.git\n  ```\n\n- Download and install a **C** compiler\n    - If you use *Windows 8/10/11* then download **Visual Studio 2017/2019/2022** from this [link](https://visualstudio.microsoft.com/downloads/) or download and install a suitable version of **clang** from this [link](https://releases.llvm.org/download.html). For **gcc**, use the suitable *MinGW* version from this [link](http://mingw-w64.org/doku.php/download).\n\n    - If you use any stable version of *Debian/Ubuntu* then run these commands in your terminal to download and install **clang** and **gcc** compilers\n\n        ```shell\n        sudo apt install clang\n        ```\n    \n        ```shell\n        sudo apt install gcc\n        ```\n\n    - In *macOS*, **clang** is the default **C** compiler. To download and install gcc, run this command in your terminal\n    \n        ```shell\n        brew install gcc\n        ```\n\n- For building on Linux 32-bit targets on a 64-bit platform, `gcc-multilib` must be installed:\n    \n    ```bash\n    sudo apt install gcc-multilib\n    ```\n\n- Download and install **CMake**\n    - For *Windows 8/10/11* download from [kitware](https://cmake.org/files/v3.19/) or [GitHub](https://github.com/Kitware/CMake/releases/tag/v3.19.6)\n\n    - If you use any stable version of *Debian/Ubuntu* then run these commands in your terminal to download and install **cmake**\n    \n        ```shell\n        sudo apt install cmake\n        ```\n\n    - To download and install **cmake** on *macOS*, run this command in your terminal\n\n        ```shell\n        brew install cmake\n        ```\n\n## Usage\n\n- Download the [latest release](https://github.com/KumarjitDas/kdapi/releases/latest) of the project according to your system specification.\n\n- For CMake projects add the _kdapi_ library _cmake_ directory path to the `CMAKE_PREFIX_PATH` variable.\n    - In CMake file\n    \n        ```cmake\n        # ...\n        list(APPEND CMAKE_PREFIX_PATH path/to/kdapi/lib/cmake)\n        # ...\n        ```\n\n    - In command line as an argument\n        \n        ```shell\n        cmake ... -DCMAKE_PREFIX_PATH=path/to/kdapi/lib/cmake ...\n        ```\n\n- Include the _kdapi.h_ header file in your C project to use KDAPI.\n\n    ```c\n    #include \"kdapi.h\"\n    ```\n\n- To build the project from source using CMake you have to provide target platform information (`KDAPI_TARGET_OS` and `KDAPI_TARGET_ARCH`. For example:\n\n    ```shell\n    cmake -DKDAPI_TARGET_OS=windows -DKDAPI_TARGET_ARCH=x64 -G Ninja -S path/to/kdapi -B path/to/build\n    ```\n\n- When building shared libraries\n\n    - Add the `KD_BUILDING_LIB` macro at the top in your source file _(.c)_ before _\"kdapi.h\"_ inclusion\n    \n        ```c\n        #define KD_BUILDING_LIB 1\n        #include \"kdapi.h\"\n        ```\n\n    - Pass the `KD_DLL=1` to CMake through command line or in your main _CMakeLists.txt_ file\n\n        ```shell\n        cmake -DKDAPI_TARGET_OS=windows -DKDAPI_TARGET_ARCH=x64 -DKD_DLL=1 -G Ninja -S path/to/kdapi -B path/to/build\n        ```\n        \n        or,\n        \n        ```cmake\n        target_compile_definitions(mylib KD_DLL=1)\n        ```\n\n### Example\n\nYou can find all the examples [here](examples). Here's a demo:\n\n```c\n#include \u003cstdio.h\u003e\n#include \"kdapi.h\"\n\nint main() {\n    printf(\"Compiler: %s\\n\", KD_COMP_STR);\n    printf(\"Target Operating System: %s\\n\", KD_OS_STR);\n    printf(\"Target CPU: %s\\n\", KD_CPU_STR);\n    return 0;\n}\n```\n\n## Roadmap\n\nSee the [open issues](https://github.com/KumarjitDas/kdapi/issues) for a list of proposed\nfeatures/functionalities (and known issues).\n\nThe list of features and functions implemented till now is given in [Project Status](#project-status).\n\n## Contributing\n\nContributions are what make the open source community such an amazing place to learn, inspire, and create. Any\ncontributions you make are greatly appreciated.\n\n- Fork this project \\[[kdapi](https://github.com/KumarjitDas/kdapi)\\]\n- Create your *Feature Branch*\n    \n    ```shell\n    git checkout -b feature/AmazingFeature\n    ```\n\n- Commit your *Changes*\n    \n    ```shell\n    git commit -m 'Added some AmazingFeature'\n    ```\n\n- Push to the Branch\n    \n    ```shell\n    git push origin feature/AmazingFeature\n    ```\n\n- Create a [pull request](https://github.com/KumarjitDas/kdapi/pulls)\n\n## Naming Convention\n\nThe KDAPI project follows a consistent naming convention to ensure readability and maintainability. Here are the key aspects of the naming convention used:\n\n- **Macro Names**: Macro names are written in uppercase letters with underscores separating words. They typically start with the prefix `KD_`.\n    - Examples: `KD_COMPILER_GCC`, `KD_OS_LINUX`, `KD_CPU_X86_64`, `KD_VERSION_MAJOR`\n\n- **Function-Like Macros**: Function-like macros also follow the uppercase with underscores convention and use parentheses to indicate parameters.\n    - Examples: `KD_EXTERN_BEGIN`, `KD_EXTERN_END`\n\n- **Constants**: Constants are defined using uppercase letters with underscores and often include a descriptive name or version number.\n    - Examples: `KD_VERSION_STR`, `KD_VERSION_MAJOR`\n\n- **File Names**: File names are in lowercase and use underscores to separate words.\n    - Examples: `kdapi.h`, `example.c`, `setup_project.cmake`\n\n## License\n\nThis project is distributed under the **BSD 2-Clause License**. See [LICENSE](LICENSE.txt) for more information.\n\n## Project Status\n\nList of functionalities/features implemented so far:\n\n- **Compiler Detection**: Macros for various compilers (Intel, GCC, LLVM, etc.).\n- **OS Identification**: Macros for target operating systems (Linux, Windows, etc.).\n- **CPU Architecture Detection**: Macros for target CPU architectures (x86, x64, ARM, etc.).\n- **Architecture Integer Size**: Macros for target CPU architecture integer size.\n- **Architecture Pointer Size**: Macros for target CPU architecture pointer(address) size.\n- **Endianness Determination**: Macros for little-endian and big-endian.\n- **C-String Identifiers**: Macros for human-readable C-string macros for compiler, OS, CPU, and endianness.\n- **DLL Handling**: Import-export macros for DLLs.\n- **Calling Conventions**: Macros for cdecl, stdcall, fastcall.\n- **Build Configuration**: CMake configuration files for shared and static builds.\n- **Example Programs**: [Examples](examples) demonstrating library usage.\n\n## Contact\n\nTwitter: [@kumarjitdas1999](https://twitter.com/kumarjitdas1999)\n\nLinkedIn: [Kumarjit Das](https://www.linkedin.com/in/kumarjit-das)\n\nE-mail: [kumarjitdas1999@gmail.com](mailto:kumarjitdas1999+github@gmail.com)\n\nProject link: [KDAPI](https://github.com/KumarjitDas/kdapi)\n\n## Versioning\n\nThis project uses **MAJOR**, **MINOR**, and **PATCH** version numbers for\nversioning (v*MAJOR.MINOR.PATCH*).\n\n- **MAJOR** version number indicates *new changes which may be incompatible with older versions*.\n- **MINOR** version number indicates *addition of backwards-compatible features*.\n- **PATCH** version number indicates *backwards-compatible bug fixes*, or minor mistake fixes like *spelling*, *character cases*, *punctuations*, and *indentation*.\n\n## Changelog\n\nThe [Changelog](CHANGELOG.md) file contains all the information about the changes made to this project till now.\n\nYou can also view the [raw](https://raw.githubusercontent.com/KumarjitDas/kdapi/main/CHANGELOG.md) version.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkumarjitdas%2Fkdapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkumarjitdas%2Fkdapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkumarjitdas%2Fkdapi/lists"}