Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
test C++ register
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//clang 3.8.0 #include <iostream> #include <array> typedef uint8_t u8; typedef uint16_t u16; typedef uint32_t u32; typedef uint64_t u64; typedef unsigned int uINT; namespace registers { template<u32 pon_def, bool single_bf> struct register_t { constexpr static u32 const PON_DEF = pon_def; constexpr static u32 const SINGLE_BF = single_bf; }; } template<u32 bitoffset, u32 bitlength, u32 mask, bool maskable, u32 pon_def, bool byte_writeable> struct registerfield_attr_t { constexpr static u32 const BITOFFSET = bitoffset; constexpr static u32 const BITLENGTH = bitlength; constexpr static u32 const MASK = mask; constexpr static bool const MASKABLE = maskable; constexpr static u32 const PON_DEF = pon_def; constexpr static bool const BYTE_WRITEABLE = byte_writeable; }; //! @brief bitfield structure of register RSU_EIRQ_S_REG (0x60000C0C). struct rsu_eirq_s_reg_t final : registers::register_t<0x00000000, true> { union { struct { uINT RSU_EIRQ_S_BUS_TIMEOUT : 4; // rws, pon_def = 0 uINT : 28; // reserved }; u32 value; }; //Bitfield attributes (BITOFFSET, BITLENGTH, MASK, MASKABLE, PON_DEF, BYTE_WRITEABLE) constexpr static registerfield_attr_t<0U, 1U, 0x00000001U, 0, false, true> const RSU_EIRQ_S_BUS_TIMEOUT_ATTR = {}; }; u32 value; volatile rsu_eirq_s_reg_t & RSU_EIRQ_S_REG = *reinterpret_cast<rsu_eirq_s_reg_t volatile *>(&value); int main() { std::cout << "Hello, world!\n"; std::cout << sizeof(rsu_eirq_s_reg_t) << std::endl; std::cout << rsu_eirq_s_reg_t::PON_DEF << std::endl; std::cout << rsu_eirq_s_reg_t::SINGLE_BF << std::endl; rsu_eirq_s_reg_t foo; foo.RSU_EIRQ_S_BUS_TIMEOUT = 1; RSU_EIRQ_S_REG.value = 5; std::cout << RSU_EIRQ_S_REG.RSU_EIRQ_S_BUS_TIMEOUT << std::endl; }
clang++
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
Compilation time: 0.72 sec, absolute running time: 0.07 sec, cpu time: 0.01 sec, memory peak: 3 Mb, absolute service time: 0,8 sec
edit mode
|
history
|
discussion