# Using libcanard on C99

**URL:** <https://forum.opencyphal.org/t/using-libcanard-on-c99/921>\
**Category:** Libcanard\
**Created:** [August 19, 2020, 11:37am UTC](https://forum.opencyphal.org/t/using-libcanard-on-c99/921 "2020-08-19T11:37:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![nacansino](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/nacansino/32/535_2.png) [@nacansino](https://forum.opencyphal.org/u/nacansino)\
**Post date:** [August 19, 2020, 11:37am UTC](https://forum.opencyphal.org/t/using-libcanard-on-c99/921/1 "2020-08-19T11:37:03Z")

</div>

Hi, it’s me again. I’m trying to compile libcanard against a proprietary compiler, but unfortunately it only supports up to C99.

What will be the risks associated if I forced libcanard (by removing the **STDC\_VERSION** check) to run on C99?

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [August 19, 2020, 2:29pm UTC](https://forum.opencyphal.org/t/using-libcanard-on-c99/921/2 "2020-08-19T14:29:30Z")

</div>

It should work if you also get rid of all static assertion checks. Can you tell us what compiler are you using?

---

<div class="post-metadata">

**Author:** ![nacansino](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/nacansino/32/535_2.png) [@nacansino](https://forum.opencyphal.org/u/nacansino)\
**Post date:** [August 20, 2020, 1:21am UTC](https://forum.opencyphal.org/t/using-libcanard-on-c99/921/3 "2020-08-20T01:21:24Z")

</div>

I am using a Green Hills Optimizing Compiler for Renesas RH850 automotive microcontrollers. The code builds as usual when removing the static assertion checks, but I am yet to verify whether the library would still function correctly (and I think it should).

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [August 20, 2020, 8:30pm UTC](https://forum.opencyphal.org/t/using-libcanard-on-c99/921/4 "2020-08-20T20:30:19Z")

</div>

Thanks. Yes, it should, because IIRC the only reason to require C11 is to have the assertion checks. You’re not the first one with this problem, actually. Do you think it would make sense to make the codebase compatible with C99? What does your compiler vendor say about the possibility of supporting C11?

---

<div class="post-metadata">

**Author:** ![nacansino](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/nacansino/32/535_2.png) [@nacansino](https://forum.opencyphal.org/u/nacansino)\
**Post date:** [August 21, 2020, 7:51am UTC](https://forum.opencyphal.org/t/using-libcanard-on-c99/921/5 "2020-08-21T07:51:07Z")

</div>

By assertion checks, I assume you mean `assert()`, since that is the only assertion function inside libcanard. As per standard as written [here](http://www.dii.uchile.cl/~daespino/files/Iso_C_1999_definition.pdf), it seems that assert() is already available on C99.

I do not have any idea about my vendor supporting C11. I didn’t bother to ask because I’m primarily using C++11 for the application-level code. And that’s the odd thing - the compiler supports up to C++14 but they did not bother to support C11.

I am not familiar with the changes introduced in C11. However, if libcanard is functioning correctly as per specifications on C99 compilers, then I think it wouldn’t hurt to make the codebase compatible. I have used Renesas CCRX and CCRH compilers in my current company - and both supports only up to C99. I would assume older companies stuck with older compilers have the same situation.

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [August 21, 2020, 8:15am UTC](https://forum.opencyphal.org/t/using-libcanard-on-c99/921/6 "2020-08-21T08:15:59Z")

</div>

By assertion checks I mean static asserts. They are not available before C11 and they are used by the DSDL serialization helpers.

Would you be inclined to submit a pull request adding support for C99?

---

<div class="post-metadata">

**Author:** ![nacansino](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/nacansino/32/535_2.png) [@nacansino](https://forum.opencyphal.org/u/nacansino)\
**Post date:** [August 22, 2020, 5:01am UTC](https://forum.opencyphal.org/t/using-libcanard-on-c99/921/7 "2020-08-22T05:01:37Z")

</div>

Sure, I’ll take a look at what we can do to make in backwards-compatible to C99.
