Skip to content

machine-wide/dbj_capi

Repository files navigation

Work in progress

dbj c api aka

dbj_capi™

Intro

On this planet there is a see of wel crafted C code ready for copy paste. Ona has to have some usage logic in order not to drawn in redundant versions of code doing the same thing equaly well.

For example

For core set of data types everuone needs, I have decided to use Troy D. Hanson uthash and the rest. There are Matias Gustavson, STB (Sean T. Barret) and a lot more diferent but equaly well crafted reusable C code. Deciding which one to use takes a lot of time. The time I do not have.

I will reuse but will waste as little time as possible in deciding what to reuse. Logic is simple: repo has to be alive and with aq lots of contributors. In that case it is a good candidate to be reused.

This is attempt to provide dbj re-usable C

The collection of top level standard C, idioms, mechanisms, functions, libs.

Meaning: this is or should be used in all of my standard C projects; and possibly all of the C++ code, I am working on.

How to use

Simple, always use it as a submodule of my MACHINE_WIDE code.

  • How to "wrangle" with VS Code and clang to make this work, you are more than qualified for 😉 , without me telling you.

Notes on Style

Two software composition techniques are on the top of my priorities (this is opposite of inheritance) :

  1. single header files
    1. thus no libraries
  2. unity builds
    1. thus faster builds

Beware: Code in here is far from sorted. But I am honestly oriented in this direction.

  • This code is standard C code.
  • This code is only Windows (10) code
    • Using the 64 bit clang-cl compiler (comes with Visual Studio 2019)
  • Let us be clear: cl.exe (aka MSVC) can not be used (gasp!)
    • this is because MSVC is not standard C compiler.
  • Why WIN32?
    • Windows is built on WIN32
      • MS STL is based on WIN32, thus all is based on WIN32
    • WIN32 is ANSI C API.
      • with some extensions but not on the level of standard C

Which C exactly, are we talking about?

standard C with all the available clang/gcc extensions.

For standard conformance, use any of the following:

-std=c90 -pedantic
-std=c99 -pedantic
-std=c11 -pedantic
-std=c17 -pedantic

One can use C17,c18,c2x or whatever. c17 is still the standard 2022 Q4.

C11 was release by ISO WG14 in 2011. There has been one Technical Corrigendum, fixing the definitions of __STDC_VERSION__ and __STDC_LIB_EXT1__.

ANSI did not issue its own versions of the 1999 or 2011 standards, adopting the ISO standards instead.

For an deeper view please see here.

From the Gandalf, himself.

What about GCC?

From the clang standard C programs point of view, is it clang or GCC most of the time is irrelevant. clang tries to be compatible with gcc as much as possible, but some gcc extensions are not implemented yet.

Feature checking macros in standard C

Whenever and wherever possible we use them. Here is clang Feature Checking Macros section.

We think this is probably the key feature of clang compiler. Please make sure you know and use them.


© 2021, 2022 by dbj at dbj dot org htpps://dbj.org/license_dbj

Languages