Skip to content

C23/C++14 platform independent implementation of C2y countof()

License

Notifications You must be signed in to change notification settings

Serge3leo/countof_ns

Repository files navigation

CMake on multiple platforms

C2y countof() platform independent implementation with C23/C++11

countof_ns() is a portable implementation of the macro countof() draft C2y by means of the C23/C++11 standards or using extensions of the C language standards of previous editions, which are supported by most compilers.

Incomplete list of supported compilers: Clang, GNU gcc, Intel (classic icc), IntelLLVM (icx), LCC (MCST Elbrus), MSVC (Visual Studio 2022), NVHPC (NVIDIA HPC Compiler), Pelles C, PGI (The Portland Group(?)), SunPro (Oracle Developer Studio).

Table of Contents

Background

Any optional sections

Install

Implementing the macro countofi_ns() consists of a single, dependency-free file include/countof_ns.h. You can simply copy this file to the desired location on the header search paths.

Alternatively, you can use FetchContent in your cmake project:

include(FetchContent)
FetchContent_Declare(
    CountofNS
    GIT_REPOSITORY https://github.com/Serge3leo/countof_ns.git
    GIT_TAG  e6b8a03f5c62a0866dda910379240f18d9082e0f # v0.6.0-pre-examples
)
FetchContent_MakeAvailable(CountofNS)

See the example: examples/cmake_fetch_content/CMakeLists.txt.

This module depends upon a knowledge of Markdown.


Any optional sections

Usage


Rationale

Any optional sections

More optional sections

Contributing

PRs accepted.

Small note: If editing the Readme, please conform to the standard-readme specification.

Disclaimer

Sorry for my best English. Alas, this file is actually a yandex translation of README.ru.md with minimal editorial changes.

License

BSD-2-Clause © 2025 Сергей Леонтьев (leo@sai.msu.ru).

About

C23/C++14 platform independent implementation of C2y countof()

Resources

License

Stars

Watchers

Forks

Packages

No packages published