source: translator/examples/swap.c @ 17cd4eb

aaron-thesisarm-ehcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationresolv-newstringwith_gc
Last change on this file since 17cd4eb was 17cd4eb, checked in by Peter A. Buhr <pabuhr@…>, 8 years ago

fixed restrict, fixed parameter copy, introduced name table for types, changed variable after to string

  • Property mode set to 100644
File size: 412 bytes
Line 
1extern "C" {
2    int printf( const char *, ... );
3}
4
5forall( type T )
6T swap( T *left, T *right ) {
7    T temp;
8    temp = *left;
9    *left = *right;
10    *right = temp;
11    return *right;
12}
13
14int main() {
15    int x = 1, y = 2;
16    printf( "%d %d\n", x, y );
17    int w;
18    w = swap( &x, &y );
19    printf( "%d %d %d\n", w, x, y );
20}
21
22// Local Variables: //
23// compile-command: "../../bin/cfa swap.c" //
24// End: //
Note: See TracBrowser for help on using the repository browser.