Using libcanard on C99

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?

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

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).

1 Like

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?

By assertion checks, I assume you mean assert(), since that is the only assertion function inside libcanard. As per standard as written here, 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.

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?

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