# SDL\_RenderGeometry and strict aliasing

**URL:** <https://discourse.libsdl.org/t/sdl-rendergeometry-and-strict-aliasing/34026>\
**Category:** SDL Development\
**Created:** [December 9, 2021, 11:52pm UTC](https://discourse.libsdl.org/t/sdl-rendergeometry-and-strict-aliasing/34026 "2021-12-09T23:52:20Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![sjr](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/sjr/32/5749_2.png) [@sjr](https://discourse.libsdl.org/u/sjr)\
**Post date:** [December 13, 2021, 6:36pm UTC](https://discourse.libsdl.org/t/sdl-rendergeometry-and-strict-aliasing/34026/21 "2021-12-13T18:36:57Z")

</div>

Am I the only one **not** using and passing around `SDL_Color` in the parts of their program that don’t touch SDL? I don’t really care about big-endian systems, since both x86 and ARM are little-endian (yes, ARM _can_ do big-endian, etc, etc, etc, but nobody uses it in big-endian mode).

Like, if I’m not storing color as a vec4 of floats, such as when pixel plotting, it’s packed into a uint32\_t.

---

<div class="post-metadata">

**Author:** ![slime](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/slime/32/3845_2.png) [@slime](https://discourse.libsdl.org/u/slime)\
**Post date:** [December 13, 2021, 6:48pm UTC](https://discourse.libsdl.org/t/sdl-rendergeometry-and-strict-aliasing/34026/22 "2021-12-13T18:48:30Z")

</div>

In my code, colors are stored in a struct of float components when working with arbitrary / high precision, and a struct of uint8 components when working with 8 bit per component precision. I have no need to encode the whole color as a 32 bit integer at all anywhere in my codebase.

I don’t use SDL’s own SDL\_Color structure, but my own struct is trivially castable to it.

---

<div class="post-metadata">

**Author:** ![Daniel\_Gibson](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/daniel_gibson/32/3010_2.png) [@Daniel\_Gibson](https://discourse.libsdl.org/u/Daniel_Gibson)\
**Post date:** [December 13, 2021, 7:01pm UTC](https://discourse.libsdl.org/t/sdl-rendergeometry-and-strict-aliasing/34026/23 "2021-12-13T19:01:18Z")

</div>

Even if the not-SDL-specific code packs the color into a `uint32_t`, how likely is is it that the generic code uses exactly the format that matches SDL\_Color - depending on endianess (if you care about it)?  
On Little Endian that `uint32_t` would be in (the equivalent of) `SDL_PIXELFORMAT_ABGR8888` format, which seems a bit obscure to me when storing the color in an integer (unless you’re explicitly targeting SDL2’s render API, in which case you could as well use its type)

[Previous page](https://discourse.libsdl.org/t/sdl-rendergeometry-and-strict-aliasing/34026.md?page=1)
