[-] avidya@programming.dev 2 points 1 month ago

GCC uses libiconv to figure out how to transcode the bytes.

[-] avidya@programming.dev 2 points 1 month ago* (last edited 1 month ago)

You can actually change this.

The compiler has an 'execution' character set that describes how characters should be interpreted at run time, and a 'source' character set, and they need not be the same.

Check this out

$ cat test_ebdic.c ; gcc -fexec-charset=EBCDIC-US test_ebdic.c ; ./a.out | xxd
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
        char data[] = "Hello";
        printf("%s\n", data);
        return EXIT_SUCCESS;
}
00000000: c885 9393 960a                           ......

The file was typed in UTF-8, and the compiler automatically translated the literal to EBCDIC-US to emit at run time. My terminal can't display this, so I view it with a hex editor.

8
The Digital Imprimatur (www.fourmilab.ch)

A timely and relevant essay about the war on General Purpose computing.

[-] avidya@programming.dev 4 points 2 months ago

Check out GLIBC, the standard libc implementation for GNU/Linux, or the easier to read, minimalist, alternative libc MUSL.

Bootlin, runs the Elixir Code Cross Referencer that lets you easily hop between files. For instance, Here is the code for printf in GLIBC.

[-] avidya@programming.dev 2 points 3 months ago

If I am not mistaken, the argument made by papers like "C is not a low level language" is that C used to be a low level language, because it fit the architecture of a PDP, but a modern computer isn't a PDP, and so C isn't low level.

13

An intresting talk on Is Everything a File, IO Models, Is C a Low Level Language, and a quick comparison on Interfacing with USB devices on Mac OS, Linux and Windows.

[-] avidya@programming.dev 2 points 3 months ago* (last edited 3 months ago)

Did you know that

	int history[10] = {0,0,0,0,0,0,0,0,0,0};  

is the same thing as

        int history[10] = {0};

And an idom in C would be to define a constant for the size like this

enum { HISTORY_MAX = 10};
int history[HISTORY_MAX] = {0};
int history_limit = HISTORY_MAX;

avidya

0 post score
0 comment score
joined 3 months ago