User Tools

Site Tools


c_language:overview

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
c_language:overview [2021/04/08 08:37] – [Things i should check out] utedassc_language:overview [2022/09/12 00:30] (current) – external edit 127.0.0.1
Line 1: Line 1:
-====== Things i should check out ======+====== C Language ====== 
 + 
 +====== Things i should read up on ======
  
   * [[https://en.cppreference.com/w/c/language/operator_precedence|Operator precedence order]]   * [[https://en.cppreference.com/w/c/language/operator_precedence|Operator precedence order]]
Line 5: Line 7:
   * [[http://c-faq.com/index.html|C FAQ]]   * [[http://c-faq.com/index.html|C FAQ]]
   * [[https://www.agner.org/optimize/calling_conventions.pdf|C++ ABI]] -- Not exclusively for C, but still relevant   * [[https://www.agner.org/optimize/calling_conventions.pdf|C++ ABI]] -- Not exclusively for C, but still relevant
 +  * [[https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html|Statements and Declarations in Expressions]] 
 +  * What inline in combination with export and static actually does [[https://stackoverflow.com/questions/6312597/is-inline-without-static-or-extern-ever-useful-in-c99|SO1]], [[https://stackoverflow.com/questions/216510/what-does-extern-inline-do|SO2]], [[https://en.cppreference.com/w/c/language/inline|CPP reference]] 
 +  * [[http://www.catb.org/esr/structure-packing/]] -- The lost art of structure packing
  
 [[http://www.underhanded-c.org/|Underhanded C Contest]] [[http://www.underhanded-c.org/|Underhanded C Contest]]
 +
 +[[http://uguu.org/sources.html|uguu]] -- Anime ascii art
 +====== IOCCC ======
  
 [[https://www.ioccc.org/|The International Obfuscated C Code Contest]] [[https://www.ioccc.org/|The International Obfuscated C Code Contest]]
  
-[[https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html|Statements and Declarations in Expressions]]+  * [[https://stackoverflow.com/questions/19298778/why-does-the-1987-korn-oneliner-print-unix|Best one-liner 1987]] 
 + 
 +====== 8 phases of translation in C ====== 
 +[[https://stackoverflow.com/questions/1476892/poster-with-the-8-phases-of-translation-in-the-c-language/1479972#1479972|stackoverflow]] 
 + 
 +<code> 
 +                       ANSI C translation phases 
 +                       ========================= 
 + 
 +          +-------------------------------------------------+ 
 +          | map physical characters to source character set | 
 +          |     replace line terminators with newlines      | 
 +          |           decode trigraph sequences             | 
 +          +-------------------------------------------------+ 
 +                                   | 
 +                                   V 
 +               +---------------------------------------+ 
 +               | join lines along trailing backslashes | 
 +               +---------------------------------------+ 
 +                                   | 
 +                                   V 
 +     +-------------------------------------------------------------+ 
 +     | decompose into preprocessing tokens and whitespace/comments | 
 +                          strip comments                         | 
 +                          retain newlines                        | 
 +     +-------------------------------------------------------------+         
 +                                   | 
 +                                   V 
 +          +------------------------------------------------+ 
 +          | execute preprocessing directives/invoke macros | 
 +          |              process included files            | 
 +          +------------------------------------------------+ 
 +                                   | 
 +                                   V 
 +   +----------------------------------------------------------------+ 
 +   | decode escape sequences in character constants/string literals | 
 +   +----------------------------------------------------------------+ 
 +                                   | 
 +                                   V 
 +                +--------------------------------------+ 
 +                | concatenate adjacent string literals | 
 +                +--------------------------------------+ 
 +                                   | 
 +                                   V 
 +              +------------------------------------------+ 
 +              | convert preprocessing tokens to C tokens | 
 +              |       analyze and translate tokens       | 
 +              +------------------------------------------+ 
 +                                   | 
 +                                   V 
 +                    +-----------------------------+ 
 +                    | resolve external references | 
 +                    |        link libraries       | 
 +                    |      build program image    | 
 +                    +-----------------------------+ 
 +</code>
 ====== Right-to-left rule ====== ====== Right-to-left rule ======
 +[[https://stackoverflow.com/questions/8392228/complicated-right-to-left-rule-when-defining-a-variable|SO thread]]
 +
 +[[https://www.reddit.com/r/learnprogramming/comments/66a4og/the_rightleft_rule_useful_for_understanding_cc/|Reddit]]
 +
 To decode the expression ''char (*(*x())[5])()'' To decode the expression ''char (*(*x())[5])()''
 <code c> <code c>
Line 23: Line 89:
 char (*(*x())[5])() : returning char char (*(*x())[5])() : returning char
 </code> </code>
 +
 +====== Pointer vs Array ======
 +They are NOT the same, despite what people say!
 +
 +<code c>
 +// Example of char array vs char pointer
 +char *str1 = "Foo"; // Pointer. "Foo" resides in TEXT-section
 +char str2[] = "Bar"; // Array. "Bar" resides in RAM, copied to DATA section during C-startup
 +
 +str1[2] = 'O'; // Illegal, undefined behaviour
 +str2[2] = 'R'; // This is fine, it alters content of RAM
 +</code>
 +
  
 ====== Const ====== ====== Const ======
c_language/overview.1617871025.txt.gz · Last modified: 2022/09/12 00:30 (external edit)

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki