fork download
  1. #include <iostream>
  2. #include <map>
  3.  
  4. #define REGISTER_PORT(map, key, value) map.insert(std::make_pair(key, (PORT_ADDR)value))
  5.  
  6. typedef volatile int* const PORT_ADDR;
  7. typedef enum {PORT0, PORT1, PORT2, PORT3, PORT4, PORT5} PORT_TYPE;
  8.  
  9. using namespace std;
  10.  
  11. int main(int argc, char* argv[])
  12. {
  13. std::map<PORT_TYPE, PORT_ADDR> portMap;
  14. REGISTER_PORT(portMap, PORT0, 0x42128005);
  15. REGISTER_PORT(portMap, PORT1, 0x42128000);
  16. REGISTER_PORT(portMap, PORT2, 0x42188004);
  17. REGISTER_PORT(portMap, PORT3, 0x42128001);
  18. REGISTER_PORT(portMap, PORT4, 0x42188005);
  19. REGISTER_PORT(portMap, PORT5, 0x42128004);
  20.  
  21. for(auto iter = portMap.begin(); iter != portMap.end(); ++iter)
  22. {
  23. printf("[key: %d, Val: %p]\n", iter->first, iter->second);
  24. }
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0s 3272KB
stdin
Standard input is empty
stdout
[key: 0, Val: 0x42128005]
[key: 1, Val: 0x42128000]
[key: 2, Val: 0x42188004]
[key: 3, Val: 0x42128001]
[key: 4, Val: 0x42188005]
[key: 5, Val: 0x42128004]