Compile a simple one-line program containing just this: #include <sport.h> Use the command line "cc21k -c -c++ foo.cpp". Warnings are issued about const members in a class with no constructor, because some of the bit fields in the SPORT register structures are declared const volatile. A possible alternative scheme is to provide an alternate C++ implementation: Declare the const volatile fields as private non-const volatile and provide inline public "getter" methods to access these fields. For example: struct __sport_transmit_control_register { /* Status bits */ #if defined(__cplusplus) private: unsigned int volatile _txs:2; /* Read only TX Buffer status */ unsigned int volatile _tuvf:1; /* Read only undeflow status */ unsigned int volatile _chnl:5; /* Read only current channel */ public: // accessors for read-only fields unsigned txs() const { return _txs; } unsigned tuvf() const { return _tuvf; } unsigned chnl() const { return _chnl; } #else unsigned int const volatile txs:2; /* Read only TX Buffer status */ unsigned int const volatile tuvf:1; /* Read only undeflow status */ unsigned int const volatile chnl:5; /* Read only current channel */ #endif .... }; Kenneth Porter Kensington Laboratories, Inc. mailto: http://www.kensingtonlabs.com |
sport.h not C++-clean
Started by ●November 7, 2000