Reputation: 449
I have already been made aware of this question, in which the OP seeks to use C++11 standards. And I understand that - regrettably - C++11 is just too new for QNX 6.5. But my question relates to the same compiler and the C99 standard, which is approximately 10 years older than the compiler being used here.
I am converting an existing QNX 6.5 project to CMake. This builds fine(ish) in Momentics, but I am falling at the first hurdle; generating the project.
I have this as my CMake file
cmake_minimum_required(VERSION 3.16)
set(CMAKE_C_STANDARD 99)
project(Analyser)
# other stuff
When I try to generate this using the QNX toolchain I get
The C compiler
"/opt/qnx650/host/linux/x86/usr/bin/qcc"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /home/user/build.analyser/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/ninja cmTC_4ee62 && [1/2] Building C object CMakeFiles/cmTC_4ee62.dir/testCCompiler.c.o
FAILED: CMakeFiles/cmTC_4ee62.dir/testCCompiler.c.o
/opt/qnx650/host/linux/x86/usr/bin/qcc -Vgcc_ntoarmle -Wc,-isysroot,/opt/qnx650/target/qnx6 -std=gnu99 -Wp,-MD,CMakeFiles/cmTC_4ee62.dir/testCCompiler.c.o.d -Wp,-MT,CMakeFiles/cmTC_4ee62.dir/testCCompiler.c.o -Wp,-MF,CMakeFiles/cmTC_4ee62.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_4ee62.dir/testCCompiler.c.o -c /home/user/build.analyser/CMakeFiles/CMakeTmp/testCCompiler.c
cc: unknown option: -std=gnu99
If I remove the CMAKE_C_STANDARD
then the project generates fine, but it does not build because it defaults to C89 I guess.
If I bypass the compiler check (CMAKE_C_COMPILER_WORKS
) then of course the project generates fine.
But building the code gets me this...
/opt/qnx650/host/linux/x86/usr/bin/qcc -Vgcc_ntoarmle -Wc,-isysroot,/opt/qnx650/target/qnx6 -I{lots of include dirs} -Wc -std=gnu99 -Wp,-MD,syslib/CMakeFiles/syslib.dir/logger.c.o.d -Wp,-MT,syslib/CMakeFiles/syslib.dir/logger.c.o -Wp,-MF,syslib/CMakeFiles/syslib.dir/logger.c.o.d -o syslib/CMakeFiles/syslib.dir/logger.c.o -c /home/user/project/syslib/logger.c
cc: unknown option: -std=gnu99
(not sure why so many options get repeated)
So the cmake compiler check wasn't just a hinderance. The thing is, this works from within Momentics
/opt/qnx650/host/linux/x86/usr/bin/qcc -Vgcc_ntoarm -c -O -Wc,-Wall -pedantic-errors -Wc,-std=gnu99 -DNDEBUG -I{lots of include dirs} -EL -DVARIANT_a -DVARIANT_le -DBUILDENV_qss /home/user/project/syslib/logger.c
I doubt that the other command line options make any difference here for making the compiler understand gnu99
(I've not looked into these yet, but I will), but if you know better then please put me right.
The question comes down to this: What must I do to use the c99 / gnu99 standard in a QNX 6.5 CMake project?
Upvotes: 0
Views: 78
Reputation: 449
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 (cc1) 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 QNX 6.5 based 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".
Upvotes: 0