u/noobdainsane

A compilation of many quirks of C?

Every language has tons of "quirks". By quirks, I mean small or hidden unusual behavior or scenarios you don't normally think about. C has lots of such quirks. For example, I just discovered sizeof('a') returns 4 not 1. 'a' defaults to an int. There are so many such quirks I have found but I can't even recall them now. Struct padding, signed overflow UB but unsigned wrap works, string pooling, char array allocates on the stack but char pointer allocates the string in read only memory, and so many more.

I would like a compilation if exists, of all such quirks. This would actually help in MCQ tests.

I have seen that in interviews, they can as the output of - printf("%d", printf("hello"));. Now I know what printf() returns, but most students don't go their way learning this and most institutions don't teach this thoroughly. I don't think this can be classified as a quirk but good to take a look at.

reddit.com
u/noobdainsane — 1 day ago

Is there a well-designed template or config that handles compiler options?

Visual Studio handles compiler flags on its own. It provides a nice UI with lots of flags to tweak the compiler flags. If you are not using an IDE, most people just use some basic and only necessary compiler flags. Not everyone has the deep knowledge to remember and list out all the compiler flags.

Using a build system like CMake, I am looking for if there exists a well laid out config or template that handles lots of compiler flags (and supports different compiler toolchains and target platform) and is easy for me to configure. Something like this should exist.

reddit.com
u/noobdainsane — 6 days ago