title: Union cannot be defined in a type specifier
body: <p>I try to include a c code library from Github in my C++ application but encountered some compile error.</p>
  
  <p>Errors for the original code:</p>
  
  <pre><code>'_u16' cannot be defined in a type specifier
  
  
  non-constant-expression cannot be narrowed from type 'int' to 'uint8_t' (aka 'unsigned char') in initializer list [-Wc++11-narrowing]
  </code></pre>
  
  <p>The application is compiled by Clang 10.0.1 using CMake on macOS with following in CMakeLists.txt:</p>
  
  <pre><code>set(CMAKE_C_STANDARD 11)
  set(CMAKE_C_STANDARD_REQUIRED ON)
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11")
  
  set(CMAKE_CXX_STANDARD 11)
  set(CMAKE_CXX_STANDARD_REQUIRED ON)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  </code></pre>
  
  <p>Following is the original code:</p>
  
  <pre><code>inline static void UInt16SetBE(void *b2, uint16_t u)
  {
      *(union _u16 { uint8_t u8[16/8]; } *)b2 = (union _u16) { (u &gt;&gt; 8) &amp; 0xff, u &amp; 0xff };
  }
  </code></pre>
  
  <p>Following is my code after adding casting to try to resolve the error:</p>
  
  <pre><code>inline static void UInt16SetBE(void *b2, uint16_t u)
  {
      *(union _u16 { uint8_t u8[16/8]; } *)b2 = (union _u16) { (uint8_t)((u &gt;&gt; 8) &amp; 0xff), (uint8_t)(u &amp; 0xff) };
  }
  </code></pre>
  
  <p>Errors after my change:</p>
  
  <pre><code>'_u16' cannot be defined in a type specifier
  </code></pre>
  
  <p>Does anyone know what the syntax of the declaration means?
  <code>*(union _u16 { uint8_t u8[16/8]; } *)b2</code></p>