Re: Atmel portok - őőőőőrület :))

Andras Tantos andras_tantos at yahoo.com
Fri Apr 23 16:08:55 CEST 2004


> Hi,
>
> Valakinek van ötlete, hogyan tudnám megcsinálni azt, hogy a
> portbeolvasásoknál ne
> PORTx-t irjak a PINx helyett? :))))
>
> Állandóan elcseszem, és már nagyon elegem van magamból... :))
>
> C-ben csak írhatónak lehet deklarálni valamit?
> Nem igen tudok róla...
> Csinálnék alias portokat csak irható típussal.
> Amire szépen warningot dobna a fordító...

C++-ban meg lehet csinalni. C-ben nem hiszem:

#include <stdio.h>

class WriteOnly {
public:
    // Copy constructor from int
    WriteOnly(const int Value) { printf("Constructor %d\n",Value); }
    // Copy operator from int
    WriteOnly operator=(const int Value) { printf("operator =
%d\n",Value); }
private:
    // Copy constructor from itself
    WriteOnly(const WriteOnly &Value) { printf("Private Constructor\n"); }
    // Copy operator to int
    int operator=(const WriteOnly Value) { printf("Provate operator =\n"); }
};

// Es persze meg egy csomo mas operatort is definialsz ahhoz,
// hogy igazan szep legyen. De innentol kezdve:

int main() {
    WriteOnly MyPort = 3; // ez mukodik
    if (MyPort != 3) { printf("This shouldn't work!\n"); } // ez forditasi
hibat ad
    return 0;
}

Udv,
Tantos Andras
<http://andras.tantos.homedns.org>






More information about the Elektro mailing list