Ignore:
Timestamp:
Apr 21, 2016, 8:24:07 AM (8 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
6812d89
Parents:
6b6597c
Message:

add -fgnu89-inline flag to compile, cleanup swap example I/O, stdlib fixes, start math library

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/examples/swap.c

    r6b6597c r6e991d6  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 16:15:11 2016
    13 // Update Count     : 65
     12// Last Modified On : Thu Apr 21 08:10:41 2016
     13// Update Count     : 69
    1414//
    1515
     
    2424
    2525        signed int i1 = -1, i2 = -2;
    26         sout | "signed int\t\t" | i1 | ' ' | i2 | "\t\t\tswap ";
     26        sout | "signed int\t\t" | i1 | i2 | "\t\t\tswap ";
    2727        swap( &i1, &i2 );
    28         sout | '\t' | i1 | ' ' | i2 | endl;
     28        sout | '\t' | i1 | i2 | endl;
    2929
    3030        unsigned int ui1 = 1, ui2 = 2;
    31         sout | "unsigned int\t\t" | ui1 | ' ' | ui2 | "\t\t\tswap ";
     31        sout | "unsigned int\t\t" | ui1 | ui2 | "\t\t\tswap ";
    3232        swap( &ui1, &ui2 );
    33         sout | '\t' | ui1 | ' ' | ui2 | endl;
     33        sout | '\t' | ui1 | ui2 | endl;
    3434
    3535        signed long int li1 = -1, li2 = -2;
    36         sout | "signed long int\t\t" | li1 | ' ' | li2 | "\t\t\tswap ";
     36        sout | "signed long int\t\t" | li1 | li2 | "\t\t\tswap ";
    3737        swap( &li1, &li2 );
    38         sout | '\t' | li1 | ' ' | li2 | endl;
     38        sout | '\t' | li1 | li2 | endl;
    3939
    4040        unsigned long int uli1 = 1, uli2 = 2;
    41         sout | "unsigned long int\t" | uli1 | ' ' | uli2 | "\t\t\tswap ";
     41        sout | "unsigned long int\t" | uli1 | uli2 | "\t\t\tswap ";
    4242        swap( &uli1, &uli2 );
    43         sout | '\t' | uli1 | ' ' | uli2 | endl;
     43        sout | '\t' | uli1 | uli2 | endl;
    4444
    4545        signed long long int lli1 = -1, lli2 = -2;
    46         sout | "signed long long int\t" | lli1 | ' ' | lli2 | "\t\t\tswap ";
     46        sout | "signed long long int\t" | lli1 | lli2 | "\t\t\tswap ";
    4747        swap( &lli1, &lli2 );
    48         sout | '\t' | lli1 | ' ' | lli2 | endl;
     48        sout | '\t' | lli1 | lli2 | endl;
    4949
    5050        unsigned long long int ulli1 = 1, ulli2 = 2;
    51         sout | "unsigned long long int\t" | ulli1 | ' ' | ulli2 | "\t\t\tswap ";
     51        sout | "unsigned long long int\t" | ulli1 | ulli2 | "\t\t\tswap ";
    5252        swap( &ulli1, &ulli2 );
    53         sout | '\t' | ulli1 | ' ' | ulli2 | endl;
     53        sout | '\t' | ulli1 | ulli2 | endl;
    5454
    5555        float f1 = 1.5, f2 = 2.5;
    56         sout | "float\t\t\t" | f1 | ' ' | f2 | "\t\tswap ";
     56        sout | "float\t\t\t" | f1 | f2 | "\t\t\tswap ";
    5757        swap( &f1, &f2 );
    58         sout | '\t' | f1 | ' ' | f2 | endl;
     58        sout | '\t' | f1 | f2 | endl;
    5959
    6060        double d1 = 1.5, d2 = 2.5;
    61         sout | "double\t\t\t" | d1 | ' ' | d2 | "\t\tswap ";
     61        sout | "double\t\t\t" | d1 | d2 | "\t\t\tswap ";
    6262        swap( &d1, &d2 );
    63         sout | '\t' | d1 | ' ' | d2 | endl;
     63        sout | '\t' | d1 | d2 | endl;
    6464
    6565        long double ld1 = 1.5, ld2 = 2.5;
    66         sout | "long double\t\t" | ld1 | ' ' | ld2 | "\t\tswap ";
     66        sout | "long double\t\t" | ld1 | ld2 | "\t\t\tswap ";
    6767        swap( &ld1, &ld2 );
    68         sout | '\t' | ld1 | ' ' | ld2 | endl;
     68        sout | '\t' | ld1 | ld2 | endl;
    6969
    7070        float _Complex fc1 = 1.5f+1.5if, fc2 = 2.5f+2.5if;
    71         sout | "float _Complex\t\t" | fc1 | ' ' | fc2 | "\tswap ";
     71        sout | "float _Complex\t\t" | fc1 | fc2 | "\tswap ";
    7272        swap( &fc1, &fc2 );
    73         sout | '\t' | fc1 | ' ' | fc2 | endl;
     73        sout | '\t' | fc1 | fc2 | endl;
    7474
    7575        double _Complex dc1 = 1.5d+1.5id, dc2 = 2.5d+2.5id;
    76         sout | "double _Complex\t\t" | dc1 | ' ' | dc2 | "\tswap ";
     76        sout | "double _Complex\t\t" | dc1 | dc2 | "\tswap ";
    7777        swap( &dc1, &dc2 );
    78         sout | '\t' | dc1 | ' ' | dc2 | endl;
     78        sout | '\t' | dc1 | dc2 | endl;
    7979
    8080        long double _Complex ldc1 = 1.5d+1.5il, ldc2 = 2.5d+2.5il;
    81         sout | "long double _Complex\t" | ldc1 | ' ' | ldc2 | "\tswap ";
     81        sout | "long double _Complex\t" | ldc1 | ldc2 | "\tswap ";
    8282        swap( &ldc1, &ldc2 );
    83         sout | '\t' | ldc1 | ' ' | ldc2 | endl;
     83        sout | '\t' | ldc1 | ldc2 | endl;
    8484
    8585        struct S { int i, j; } s1 = { 1, 2 }, s2 = { 2, 1 };
    86         ofstream * ?|?( ofstream * os, S s ) { return os | s.i | ' ' | s.j; }
    87         sout | "struct S\t\t" | s1 | "  " | s2 | "\t\tswap ";
     86        ofstream * ?|?( ofstream * os, S s ) { return os | s.i | s.j; }
     87        sout | "struct S\t\t" | s1 | "," | s2 | "\t\tswap ";
    8888        swap( &s1, &s2 );
    89         sout | '\t' | s1 | "  " | s2 | endl;
     89        sout | '\t' | s1 | "," | s2 | endl;
    9090} // main
    9191
Note: See TracChangeset for help on using the changeset viewer.