{"id":21730457,"url":"https://github.com/kumarjitdas/types","last_synced_at":"2025-03-20T23:23:51.932Z","repository":{"id":246818175,"uuid":"821807628","full_name":"KumarjitDas/types","owner":"KumarjitDas","description":"A simple, header-only C library designed to provide types with sizes.","archived":false,"fork":false,"pushed_at":"2024-07-11T19:46:43.000Z","size":107,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-25T20:09:34.689Z","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-29T13:45:59.000Z","updated_at":"2024-07-06T07:35:55.000Z","dependencies_parsed_at":"2024-07-11T22:17:32.094Z","dependency_job_id":null,"html_url":"https://github.com/KumarjitDas/types","commit_stats":null,"previous_names":["kumarjitdas/types"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KumarjitDas%2Ftypes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KumarjitDas%2Ftypes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KumarjitDas%2Ftypes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KumarjitDas%2Ftypes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KumarjitDas","download_url":"https://codeload.github.com/KumarjitDas/types/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244707445,"owners_count":20496734,"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.966Z","updated_at":"2025-03-20T23:23:51.908Z","avatar_url":"https://github.com/KumarjitDas.png","language":"CMake","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TYPES\n\nTYPES is a simple, header-only C library designed to provide types with sizes. This project targets both Windows and GNU/Linux (32-bit and 64-bit) platforms. The library aims to help developers easily specify the size of a type instead of relying on the compiler/OS/CPU architecture and macros.\n\n## Table of Contents\n\n- [Features](#features)\n- [Requirements](#requirements)\n- [Usage](#usage)\n- [Dependency](#dependency)\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\n1. **Type Definitions**\n   - Added comprehensive type definitions:\n        - Boolean: `bool`\n        - Signed integers: `i8`, `i16`, `i32`, `i64`, `imin`, `imax`\n        - Unsigned integers: `u8`, `u16`, `u32`, `u64`, `umin`, `umax`, `usize`\n        - Other types: `byte`, `charcode`\n        - Floating points: `f32`, `f64`, `fmin`, `fmax`\n        - General purpose: `any`\n\n2. **Type Pretend Macros**\n   - `TYPES_PRETEND_64BIT_INTEGER`: Makes 64-bit types act as 32-bit types for compatibility purposes.\n\n3. **Integer and Pointer Size Checks**\n   - `TYPES_64BIT_INTEGER`: Checks if the compiler, OS, and CPU support 64-bit integers.\n   - `TYPES_32BIT_INTEGER`: Checks if the compiler, OS, and CPU support 32-bit integers.\n   - `TYPES_64BIT_POINTER`: Checks if the compiler, OS, and CPU support 64-bit pointers.\n   - `TYPES_32BIT_POINTER`: Checks if the compiler, OS, and CPU support 32-bit pointers.\n\n4. **Type Boundaries and Sizes**\n   - `MIN_\u003cTYPE_NAME\u003e`: Macro to get the minimum value of a type.\n   - `MAX_\u003cTYPE_NAME\u003e`: Macro to get the maximum value of a type.\n   - `SZ_\u003cTYPE_NAME\u003e`: Macro to get the size of a type.\n\n5. **Format Specifiers and Type Casts**\n   - `FMTSP_\u003cTYPE_NAME\u003e`: Macro to get standard C format specifiers.\n   - `FSBTC_\u003cTYPE_NAME\u003e`: Function-like macro to type cast the library types.\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/types.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### Dependency\n\nThe **types** library depends on the **kdapi** library. Ensure that you have the **kdapi** library available in your project. If you do not provide the location of the **kdapi** CMake targets, the **types** library will attempt to download the **kdapi** library and place it in the _external_ directory inside the build tree.\n\n#### Including _kdapi_\n\n- Download the `kdapi` library from the official [repository](https://github.com/KumarjitDas/kdapi/releases/latest) or [source](https://github.com/KumarjitDas/kdapi/archive/refs/tags/v1.2.0.zip).\n- Provide the cmake-targets path in either inside root cmake file or in the command line\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## Usage\n\n- Download the [latest release](https://github.com/KumarjitDas/types/releases/latest) of the project according to your system specification.\n\n- For CMake projects add the _types_ 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/types/lib/cmake)\n        # ...\n        ```\n\n    - In command line as an argument\n\n        ```shell\n        cmake ... -DCMAKE_PREFIX_PATH=path/to/types/lib/cmake ...\n        ```\n\n- Include the _types.h_ header file in your C project to use KDAPI.\n\n    ```c\n    #include \"types.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/types -B path/to/build\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 \"types.h\"\n\nint main() {\n    printf(\"TYPES Version: %s\\n\", TYPES_VERSION_STR);\n    \n    i8 val8i = 128;\n    u32 val32u = 654321;\n    \n    printf(\"val8i: \" FMTSP_I8 \",  val32u = \" FMTSP_U32 \"\\n\", FSBTC_I8(val8i), FSBTC_U32(val32u));\n    \n    return 0;\n}\n```\n\n## Roadmap\n\nSee the [open issues](https://github.com/KumarjitDas/types/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 \\[[types](https://github.com/KumarjitDas/types)\\]\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/types/pulls)\n\n## Naming Convention\n\nThe TYPES 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- **Macro Definitions:**\n    - Macro names are written in uppercase letters. They typically start with the prefix `TYPES_`.\n    - Words are separated by underscores (`_`).\n    - Example: `TYPES_VERSION_MAJOR`, `TYPES_DEFINED_TYPE_BOOL`.\n\n- **Type Definitions:**\n    - Type names are in lowercase.\n    - Use of prefixes for type groups, such as `kd_types__type_` for internal types.\n    - Example: `kd_types__type_i64_`, `bool`, `i8`.\n\n- **Enums:**\n    - Enum names follow a similar lowercase pattern, with names indicating boolean values.\n    - Example: `kd_types__type_bool_` with values `false` and `true`.\n\n- **Function-like Macros:**\n    - Macros that behave like functions are in uppercase with parameters in parentheses.\n    - Example: `TYPES_I64(x)`, `TYPES_U32(x)`, `FSBTC_U32(x)`.\n\n- **Constant Values:**\n    - Constants follow the uppercase convention and often include type indications.\n    - Example: `MIN_I8`, `MAX_I32`, `SZ_BOOL`, `FMTSP_I8`.\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- **Type definitions**: `bool`, `i8`, `i16`, `i32`, `i64`, `imin`, `imax`, `u8`, `u16`, `u32`, `u64`, `umin`, `umax`, `usize`, `byte`, `charcode`, `f32`, `f64`, `fmin`, `fmax`, and `any`.\n- **Macro `TYPES_PRETEND_64BIT_INTEGER`**: Makes 64-bit types act as 32-bit types.\n- **Macro `TYPES_DEFINED_TYPE_\u003cTYPE_NAME\u003e`**: Checks if a type is defined.\n- **Macro `TYPES_DEFINED_TYPEVAL_\u003cVALUE_NAME\u003e`**: Checks if a constant value of a type is defined.\n- **Macro `TYPES_64BIT_INTEGER`**: Checks if the compiler, OS, and CPU support 64-bit integers.\n- **Macro `TYPES_32BIT_INTEGER`**: Checks if the compiler, OS, and CPU support 32-bit integers.\n- **Macro `TYPES_64BIT_POINTER`**: Checks if the compiler, OS, and CPU support 64-bit pointers.\n- **Macro `TYPES_32BIT_POINTER`**: Checks if the compiler, OS, and CPU support 32-bit pointers.\n- **Macro `MIN_\u003cTYPE_NAME\u003e`**: Gets the minimum value of a type.\n- **Macro `MAX_\u003cTYPE_NAME\u003e`**: Gets the maximum value of a type.\n- **Macro `SZ_\u003cTYPE_NAME\u003e`**: Gets the size of a type.\n- **Macro `FMTSP_\u003cTYPE_NAME\u003e`**: Gets compatible standard C format specifier of a type.\n- **Macro `FMTSP_\u003cTYPE_NAME\u003e(x)`**: Gets suitable type cast of a type.\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: [TYPES](https://github.com/KumarjitDas/types)\n\n## Versioning\n\nThis project uses **MAJOR**, **MINOR**, and **PATCH** version numbers for versioning (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/types/main/CHANGELOG.md) version.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkumarjitdas%2Ftypes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkumarjitdas%2Ftypes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkumarjitdas%2Ftypes/lists"}