C coding

garbage collection
mkirchner

linked lists
http://www.codeofhonor.com/blog/avoiding-game-crashes-related-to-linked-lists and github code https://github.com/webcoyote/coho/blob/master/Base/List.h

scope
https://publications.gbdirect.co.uk//c_book/chapter8/declarations_and_definitions.html  -- https://stackoverflow.com/questions/7059800/why-do-structure-definitions-have-internal-linkage https://stackoverflow.com/questions/6316987/should-struct-definitions-go-in-h-or-c-file?rq=1 which refs https://en.wikipedia.org/wiki/Opaque_pointer https://stackoverflow.com/questions/330793/how-to-initialize-a-struct-in-accordance-with-c-programming-language-standards?rq=1 https://stackoverflow.com/questions/4136888/declaring-a-struct-in-h-file-and-implementing-in-c-file?noredirect=1&lq=1 https://stackoverflow.com/questions/64315674/recognising-structs-inside-header-files-in-c?noredirect=1&lq=1

resources
https://github.com/kozross/awesome-c http://libcello.org/learn/a-fat-pointer-library fat pointers https://www.raspberrypi.org/blog/an-introduction-to-c-gui-programming-the-new-book-from-raspberry-pi-press/ from https://github.com/epccs/GtkExample (Arduino irrigation). https://codeyarns.com/2017/11/02/how-shared-library-locations-are-found-at-runtime/ https://codeyarns.com/2014/01/14/how-to-add-library-directory-to-ldconfig-cache/ /etc/ld.so.conf as sudo and add a new line with the library directory. In this case, we add /opt/foobar/lib. http://man7.org/conf/lca2006/shared_libraries/index.html https://codeyarns.com/2013/12/24/how-to-set-c-or-c-compiler-for-cmake/ Nvidia cuda blade install

book reviews
https://www.embedded.com/c-for-everyone/ C for Everyone, by Richard Man and CJ Willrich, is a new 400 page book covering the C language, with an emphasis on using it in embedded systems. I

github
https://github.com/a-p-jo Collection of C99 dynamic array implementations. Generic C99 Singly & Doubly Linked List Implementation with OOP, ranges, custom loops and more. CLIp is a clipboard manager for a command line interface written in 100% standard C only. Pipe to it to copy, pipe from it to paste. https://github.com/MomentsInGraphics/vulkan_renderer from https://momentsingraphics.de/ToyRendererOverview.html

https://github.com/o3de/o3de gaming engine procedural based without stuffing the struct see https://news.ycombinator.com/item?id=27751358

https://github.com/godotengine/godot gaming engine procedural based, but stuffing the struct. https://godotengine.org/article/why-isnt-godot-ecs-based-game-engine ECS is a design pattern commonly used in video games (although not very often used in the rest of the software industry) which consists of having a base Entity (a container object) and Components that can be added upon it. Components provide data and the means to interact with the whole world. Finally, Systems work independently and do actions on every similar component.

This design became common in game engines and libraries in the early 2010s. The main appeal (besides architecture) is the fact that component data can be placed in contiguous memory, improving cache access. This is a common form of data-oriented optimization.

Architecturally wise, ECS aims to replace inheritance, by favouring composition, similar to how interfaces or multiple inheritance works in OOP. The key advantage in ECS is that components are dynamic (can be added or removed in run-time).

gists
https://gist.github.com/Gerjo/3939313 Simple program to demonstrate a couple uses for pointers. This program was written so I could learn more about how to apply pointers and their syntax. https://gist.github.com/mrnugget/6208844 cheat sheet https://denniskubes.com/2017/01/24/the-5-minute-guide-to-c-pointers/ https://denniskubes.com/2012/08/19/pointers-and-arrays-in-c/

https://denniskubes.com/2013/03/22/basics-of-function-pointers-in-c/ see https://www.youtube.com/watch?v=axngwDJ79GY with https://pastebin.com/rirpBxGU function pointers. Ref Oop in c

https://gist.github.com/emekoi/a97f6009fba45a0facb070ee4448b5f3 arrays

pages
http://www.gamepipeline.org by Eskil Steenberg "How I program c" download code from http://www.quelsolaar.com/mergesource.zip

static code analysis

 * https://www.owasp.org/index.php/Source_Code_Analysis_Tools
 * https://en.wikipedia.org/wiki/Coverity
 * https://en.wikipedia.org/wiki/List_of_tools_for_static_code_analysis

https://zeroturnaround.com/rebellabs/developers-guide-static-code-analysis-findbugs-checkstyle-pmd-coverity-sonarqube/2/

c2man code analysis
converts c code a man page.
 * http://nixdoc.net/man-pages/linux/man1/c2man.1.html
 * https://pastebin.com/4SGRvtRw Install script

Documentation

 * https://en.wikipedia.org/wiki/Comparison_of_documentation_generators

http://www.eclipse.org/downloads/packages/eclipse-ide-cc-linux-developers-includes-incubating-components/indigor

http://lttng.org/

Linux tools such as GCov, GProf, OProfile, and Valgrind. Visualization and analysis plugins for Linux tracing tools LTTng and SystemTap are also present https://en.wikipedia.org/wiki/List_of_performance_analysis_tools#C_and_C.2B.2B


 * https://en.wikipedia.org/wiki/Gcov, http://www.linux-mag.com/id/1409/
 * https://en.wikipedia.org/wiki/OProfile
 * https://en.wikipedia.org/wiki/SystemTap

https://en.wikipedia.org/wiki/List_of_performance_analysis_tools

https://en.wikipedia.org/wiki/Profiling_(computer_programming)

http://valgrind.org/

https://en.wikipedia.org/wiki/Splint_(programming_tool)

https://en.wikipedia.org/wiki/List_of_tools_for_static_code_analysis#C.2C_C.2B.2B

https://en.wikipedia.org/wiki/Static_program_analysis

quora
https://code.quora.com/Object-Oriented-Programming-in-C-A-Deep-Dive https://www.quora.com/Why-is-C-and-C++-such-spectacular-examples-of-incompetence dereference null pointer https://www.quora.com/If-Linus-Torvalds-doesnt-like-C-at-all-why-is-some-of-the-Linux-Kernel-written-in-it

oop in c
http://www.planetpdf.com/codecuts/pdfs/ooc.pdf frm https://stackoverflow.com/questions/415452/object-orientation-in-c?rq=1

youtube
https://www.youtube.com/watch?v=u1e0gLoz1SU header files by https://www.youtube.com/@CodeVault https://www.youtube.com/watch?v=NeOTr0u7ALk header files, extern from @JacobSorber https://www.youtube.com/watch?v=qqtmtuedaBM Kris Jordan https://www.youtube.com/watch?v=KJgsSFOSQv0&list=PLWKjhJtqVAbmUE5IqyfGYEYjrZBYzaT4m freecodecamp several hour playlist https://www.youtube.com/watch?v=xLetJpcjHS0&list=PLBlnK6fEyqRj9lld8sWIUNwlKfdUoPd1Y nesoacademy 141 vids https://www.youtube.com/watch?v=CpjVucvAc3g&list=PL2_aWCzGMAwLZp6LMUKI3cc7pgGsasm2_&index=7 codeschool pointers in c. https://www.youtube.com/watch?v=ec-Cd4jKFWc&list=PLxCzCOWd7aiGmiGl_DOuRMJYG8tOVuapB gatesmashers 47 vids https://www.youtube.com/watch?v=2ybLD6_2gKM One of the hardest things for new programmers to learn is pointers. Whether its single use pointers, pointers to other pointers, pointers to structures, something about the concept drives new programmers crazy. The C programming languages is recognized as one of the most difficult programming languages to learn. The reason for this is the limitless power you have over memory management, which comes from pointers. In this video, I show you what a pointer is, as it applies to low level memory access. Also, we talk about pointer syntax in C and how you can better understand the pointer syntax by converting it to English. And we wrap the video up by asking "why do we care?". https://www.youtube.com/watch?v=YzBgXpwm02w malware

reddit
https://www.reddit.com/r/arduino/comments/2tyagj/structs_and_progmem/

links
https://archive.ph/jGPed why not replace c with Cpp? https://www.reddit.com/r/C_Programming/comments/3al544/damien_katz_the_unreasonable_effectiveness_of_c/ see https://archive.ph/RfIeK for archive of article Oop in c vlang, rust https://makefiletutorial.com/ https://c-faq.com/ https://archive.ph/SsehB If you're talking standard, portable C++, then the answer is no, there are several things C does that C++ cannot do. C++ cannot declare same-type pointers to be non-aliasing. C does it with the keyword "restrict" (restrict type qualifier), C++ compilers usually have non-portable ways to do the same, since it's a very important and irreplaceable language feature. C++ cannot allocate an array of runtime bound on the stack, see Array declaration. There is a proposal to add that to C++, especially since many compilers support such arrays as a non-portable extension, but it's been failing for various reasons. The workaround is the non-standard alloca, perhaps hidden in an allocator. C++ cannot initialize a struct if the order of its members is not known, cannot initialize a union to non-first variant, and cannot selectively initialize array elements, since it does not have C's designated initializers - see Struct and union initialization and Array initialization (the workaround is to initialize everything and then assign each member that needs a non-zero value, which is annoying whenever I have to deal with C APIs)

I can think of a few others, which aren't that major, in my opinion: C++ cannot form (and doesn't really need) anonymous objects with lvalue access, in C those are compound literals C++ cannot select expressions based on the argument type. In C that is Generic selection -- C++ has overloading instead C++ has no pure imaginary numbers (although few C compilers implemented pure imaginary numbers): Arithmetic types (and in general, C's approach to floating-point numbers is far more robust than C++'s in several important ways). C++ approach seems to use libraries.

C++ doesn't have flexible array members: a C struct can have an array of arbitrary length as its last element (Struct declaration ), C++ doesn't really need that and it breaks the whole type-object-size relationship. C++ formally does not support type punning for unrelated types (C does, through unions), but most compilers define it for C++ as an extension

There also are dozens of valid C code constructs that are invalid C++ (or worse, valid C++ that does something different) - tentative definitions, implicit casts from void*, anonymous structs, static array indices, etc - I tried to focus on actual concepts that have no replacements. See Torvalds on C++. michael barr