Changeset df699e0 for doc/theses
- Timestamp:
- May 24, 2024, 2:18:56 PM (7 months ago)
- Branches:
- master
- Children:
- a4808ad
- Parents:
- c721105
- Location:
- doc/theses/mike_brooks_MMath/programs
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/mike_brooks_MMath/programs/bkgd-c-tyerr.c
rc721105 rdf699e0 21 21 22 22 // Local Variables: // 23 // compile-command: "sed -f sedcmd bkgd-c-tyerr.c | gcc -x c -" //23 // compile-command: "sed -f sedcmd bkgd-c-tyerr.c | gcc-11 -Wall -Wextra -x c -" // 24 24 // End: // -
doc/theses/mike_brooks_MMath/programs/bkgd-carray-arrty.c
rc721105 rdf699e0 34 34 float ar[10]; 35 35 static_assert( sizeof(float) == 4 ); $\C{// floats (array elements) are 4 bytes}$ 36 static_assert( sizeof(void *) == 8 ); $\C{// pointers are 8 bytes}$36 static_assert( sizeof(void *) == 8 ); $\C{// pointers are 8 bytes}$ 37 37 static_assert( sizeof(ar) == 40 ); $\C{// array}$ 38 38 static_assert( sizeof(&ar) == 8 ); $\C{// pointer to array}$ … … 154 154 155 155 // Local Variables: // 156 // compile-command: "sed -f sedcmd bkgd-carray-arrty.c | gcc -x c -" //156 // compile-command: "sed -f sedcmd bkgd-carray-arrty.c | gcc-11 -Wall -Wextra -x c -" // 157 157 // End: // -
doc/theses/mike_brooks_MMath/programs/bkgd-carray-decay.c
rc721105 rdf699e0 1 1 #include <assert.h> 2 2 int main() { 3 float a [10]; $\C{// array}$4 float (*pa)[10] = &a ; $\C{// pointer to array}$5 float a0 = a [0]; $\C{// element}$6 float * pa0 = &(a [0]); $\C{// pointer to element}$3 float ar[10]; $\C{// array}$ 4 float (*pa)[10] = &ar; $\C{// pointer to array}$ 5 float a0 = ar[0]; $\C{// element}$ 6 float * pa0 = &(ar[0]); $\C{// pointer to element}$ 7 7 8 float * pa0x = a ; $\C{// (ok)}$8 float * pa0x = ar; $\C{// (ok)}$ 9 9 assert( pa0 == pa0x ); 10 assert( sizeof(pa0x) != sizeof(a ) );10 assert( sizeof(pa0x) != sizeof(ar) ); 11 11 12 12 void f( float x[10], float * y ) { … … 14 14 static_assert( sizeof(y) == sizeof(void *) ); 15 15 } 16 f( 0,0);16 f( 0, 0 ); 17 17 18 18 // reusing local var `float a[10];`} 19 19 float v; 20 f( a , a );$\C{// ok: two decays, one into an array spelling}$20 f( ar, ar ); $\C{// ok: two decays, one into an array spelling}$ 21 21 f( &v, &v ); $\C{// ok: no decays; a non-array passes to an array spelling}$ 22 22 … … 33 33 static_assert( sizeof(x) == sizeof(void *) ); 34 34 } 35 static_assert( sizeof(a ) == 10 * sizeof(float) );36 decay( a);35 static_assert( sizeof(ar) == 10 * sizeof(float) ); 36 decay( ar ); 37 37 38 38 void no_decay( float (*px)[10] ) { … … 40 40 } 41 41 static_assert( sizeof(*pa) == 10 * sizeof(float) ); 42 no_decay( pa);42 no_decay( pa ); 43 43 } 44 44 45 45 // Local Variables: // 46 // compile-command: "sed -f sedcmd bkgd-carray-decay.c | gcc -x c -" //46 // compile-command: "sed -f sedcmd bkgd-carray-decay.c | gcc-11 -Wall -Wextra -x c -" // 47 47 // End: // -
doc/theses/mike_brooks_MMath/programs/bkgd-carray-mdim.c
rc721105 rdf699e0 14 14 15 15 int main() { 16 float a [3][10];17 static_assert(sizeof(float) ==4); $\C{// floats (atomic elements) are 4 bytes}$18 static_assert(sizeof(void*) ==8); $\C{// pointers are 8 bytes}$16 float ar[3][10]; 17 static_assert(sizeof(float) == 4); $\C{// floats (atomic elements) are 4 bytes}$ 18 static_assert(sizeof(void*) == 8); $\C{// pointers are 8 bytes}$ 19 19 20 static_assert(sizeof( a) == 120); $\C{// the array, float[3][10]}$21 static_assert(sizeof( a[0] ) == 40);$\C{// its first element, float[10]}$22 static_assert(sizeof( a[0][0] ) == 4); $\C{// its first grand element, float}$20 static_assert(sizeof(ar) == 120); $\C{// the array, float[3][10]}$ 21 static_assert(sizeof(ar[0]) == 40); $\C{// its first element, float[10]}$ 22 static_assert(sizeof(ar[0][0]) == 4); $\C{// its first grand element, float}$ 23 23 24 static_assert(sizeof(&(a )) == 8); $\C{// pointer to the array, float(*)[3][10]}$25 static_assert(sizeof(&(a [0])) == 8); $\C{// pointer to its first element, float(*)[10]}$26 static_assert(sizeof(&(a [0][0])) == 8); $\C{// pointer to its first grand-element, float*}$24 static_assert(sizeof(&(ar)) == 8); $\C{// pointer to the array, float(*)[3][10]}$ 25 static_assert(sizeof(&(ar[0])) == 8); $\C{// pointer to its first element, float(*)[10]}$ 26 static_assert(sizeof(&(ar[0][0])) == 8); $\C{// pointer to its first grand-element, float*}$ 27 27 28 float (*pa )[3][10] = &(a);29 float (*pa0 ) [10] = &(a[0]);30 float *pa00 = &(a[0][0]);28 float (*pa)[3][10] = &(ar); 29 float (*pa0)[10] = &(ar[0]); 30 float *pa00 = &(ar[0][0]); 31 31 32 static_assert((void*)&a == (void*)&(a[0]));33 static_assert((void*)&a == (void*)&(a[0][0]));32 static_assert((void*)&ar == (void*)&(ar[0] )); 33 static_assert((void*)&ar == (void*)&(ar[0][0])); 34 34 35 assert( (void *) pa == (void *) pa0 35 assert( (void *) pa == (void *) pa0 ); 36 36 assert( (void *) pa == (void *) pa00 ); 37 37 … … 41 41 b[i] = malloc(sizeof(float[10])); 42 42 } 43 a [2][3];43 ar[2][3]; 44 44 b[2][3]; 45 45 /* … … 50 50 51 51 // Local Variables: // 52 // compile-command: "sed -f sedcmd bkgd-carray-mdim.c | gcc -x c -" //52 // compile-command: "sed -f sedcmd bkgd-carray-mdim.c | gcc-11 -Wall -Wextra -x c -" // 53 53 // End: // -
doc/theses/mike_brooks_MMath/programs/lst-issues-attach-reduction.hpp
rc721105 rdf699e0 101 101 class list { 102 102 struct node { 103 LIST_ENTRY(node) links;104 El elem;103 @LIST_ENTRY(node) links;@ 104 @El elem;@ 105 105 }; 106 106 LIST_HEAD(Impl, node); … … 111 111 } 112 112 void push_front( const El & src ) { 113 node * n = new node();113 node * n = @new node()@; 114 114 n->elem = src; 115 115 LIST_INSERT_HEAD(&impl, n, links);
Note: See TracChangeset
for help on using the changeset viewer.