Live data from Hacker News

My personal C coding style as of late 2023

nullprogram.com

461–466 of 466 posts

Re: My personal C coding style as of late 2023

#461
post #460
post #356

Earlier quoted context omitted.

I do most of my programming in a binary world.

You do none. You program FOR the binary world, but in a complex 3D reality

I've tried programming by moving physical objects, but I've found it's generally easier if you use a digital computer.

Re: My personal C coding style as of late 2023

#462
post #460
post #356

Earlier quoted context omitted.

I do most of my programming in a binary world.

You do none. You program FOR the binary world, but in a complex 3D reality

Haha, you have no idea how powerful my dissociation is! I could very well be programming in a binary world, if my dissociative identity is linked to the computer!!

Jokes aside though, I doubt that no programmers are immersed in the computer while they code. It totally is a different world, just implemented inside this one.

Re: My personal C coding style as of late 2023

#463
post #262

Earlier quoted context omitted.

I"m even not agreeing with the const part. The standard did define const API"s, so why shouldn"t we follow? I know that C const are only half of C++ consts, but still. Still catching const errors somewhere because I do use const in APIs. I only agree with "Declare all functions static except for entry points". s8(s) is only for literal strings, it should be called s8_c instead and keep s8 for the default ctor. The st…

Can you explain the static functions thing? What’s the benefit of declaring all functions static if you’re compiling them as a single translation unit anyway?

Static means only visible for that translation unit. So they are not global. Only global inside the file.

Re: My personal C coding style as of late 2023

#464
post #16

Earlier quoted context omitted.

Computer architecture is optimized for 32+ bit aligned access to most things. The gain is (usually, but not always!) performance.

I'm afraid you are only slightly correct. Architectures are generally optimized for aligned access (or disallow unaligned access), but what counts as "aligned" is different for each type. A char type that is used for a bool can be accessed on any byte boundary because the alignment of a char is 1. The alignment of a 32-bit value is 4. However, architectures are generally more optimized for 32-bit operations in regist…

[deleted]

Re: My personal C coding style as of late 2023

#465

Earlier quoted context omitted.

Not sure about 64-bit `int`, but it is 16-bit on some 16-bit micros, such as the AVR line (used by the original Arduino).

Ti dsps have 48bits for long.

Yep. DSPs always have weird architectures, but in most cases, one isn't compiling the same code for multiple DSP architectures. As an example, the C2000 line has a 16-bit `char`; There is no support for "bytes".
Post reply on HN