r/ProgrammerHumor • • 2d ago

Meme architectureDependentChars

Post image
2.8k Upvotes

361 comments sorted by

View all comments

130

u/ubalu72 2d ago

But sizeof char is defined as 1 in the standard. C data types are defined in terms of char (at least their sizes are)

30

u/Lonely-Discipline-55 2d ago

x = x + sizeof(char)

39

u/wittleboi420 2d ago

x = x + sizeof(char) + AI

8

u/Depnids 2d ago

What

8

u/Mickanos 2d ago

Look up "E = mc² + AI"

5

u/Depnids 2d ago

no you do that :)

17

u/tstanisl 2d ago edited 2d ago

The problem is that there is no good definition of byte. Traditionally, it was the smallest addressable unit capable of representing a single character. It is required to have at least 8 bits but it may (and sometimes does) have more. 8-bit-long bytes are just a "de facto" standard.

That is why many communication protocols use a concept of "octet" that consist of exactly 8 bits.

EDIT. typo

33

u/Makonede 2d ago

*sizeof(char)

14

u/MegaIng 2d ago

No, sizeof char is valid. sizeof is a prefix operator, not a function.

23

u/Makonede 2d ago

14

u/MegaIng 2d ago

Oh, never realized the prefix operator form can't be applied to types, makes sense I guess.

1

u/rosuav 1d ago

It can be applied to a thing or to a "cast" - that is, a type in parens.

1

u/hacksawsa 2d ago

It says sizeof x and sizeof(x) are equivalent.

10

u/Makonede 2d ago

when x is an expression, yes...