nasa / osal

The Core Flight System (cFS) Operating System Abstraction Layer (OSAL)
Apache License 2.0
546 stars 213 forks source link

Designated initializer in `osapi-clock.h` header breaks C++ compilation unit. #1365

Closed jhnphm closed 1 year ago

jhnphm commented 1 year ago

Describe the bug Designated initializer in osapi-clock.h header breaks C++ compilation unit. C++ does not support this until C++20

To Reproduce #include "cfe.h" in a C++ compilation unit Build file, observe error.

Expected behavior Successful compilation

Code snips Instance of designated initializer used here: https://github.com/nasa/osal/blob/fa9671fa608ff5113f24990a78e6e7f8d47eb392/src/os/inc/osapi-clock.h#L253

Other instances in OS_TimeFromTotalSeconds, OS_TimeFromTotalMilliseconds, OS_TimeFromTotalMicroseconds, OS_TimeFromTotalNanoseconds. Issue seems to have been introduced in https://github.com/nasa/osal/pull/1310 .

System observed on:

Additional context Inline header functions should use C++03 (latest standard supported by VxWorks 6.9) compatible constructs.

Reporter Info John N Pham, Northrop Grumman

jphickey commented 1 year ago

I will look at this. For now, if you wanted to patch your code, just remove the .ticks = designation part, it should work fine (there is just one member in this wrapper object).

We don't currently validate the OSAL headers for use in C++ at all, we should re-evaluate if this is something we should consider adding to our workflows. I know there are a handful of C++ users out there.