79155834

Date: 2024-11-04 14:37:03
Score: 1
Natty:
Report link

This document from Blackberry / QNX 6.5 on the qcc compiler interface explains that qcc does not understand the -std argument.

The document suggests we pass certain options to the compiler thusly

-W phase,arg[,arg ...]
    Pass the specified option and its arguments through to a specific phase:

        p — preprocessor
        c — compiler
        l — linker
        a — assembler.

So to compile for C99 we should invoke qcc as

qcc -Wc,-std=c99 {other parameters} [source file]

CMake cannot do this for you when you add set(CMAKE_C_STANDARD 99) to your CMake project.
One possible workaround I am working with does...

if (CMAKE_C_COMPILER_VERSION GREATER 4.4.2)
    set(CMAKE_C_STANDARD 99)
else()
    add_compile_options(
        $<$<COMPILE_LANGUAGE:C>:-Wc,-std=gnu99>
    )
endif()

Please note that these instructions apply to QNX 6.5 only!

As of QNX 7, the -std argument is supported by qcc and you should be able to nominate the C standard in the way CMake intended without any of this "fuss".

Reasons:
  • Blacklisted phrase (1): This document
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: iwarv