Add support for QNX
Modifications:
- Change
__QNXNTO__to__QNX__because__QNXNTO__is deprecated - In xmltest.cpp, do not print nullptr because it would crash in QNX
- Install tests for QNX
Build and test instuction for QNX: https://github.com/chachoi-world/qnx-ports/blob/main/tinyxml2/README.md
Thanks.
- The "install" section for QNX is above the rest of the installs - and does QNX really need something unique there?
- I don't think any system can print null strings. The changes to test looks like it may be hiding a bug
Hi, @leethomason
Thanks for responding to my pull request.
The "install" section for QNX is above the rest of the installs - and does QNX really need something unique there?
Yes, QNX is cross compiled from a Ubuntu machine, so xmltest and resources have to be installed to the QNX SDP (Software Development Platform) which is like an SDK for embedded targets so that users would be able to pick up the built xmltest and resources and put them on an embedded target to test.
I don't think any system can print null strings. The changes to test looks like it may be hiding a bug
I tested this sample program on my Ubuntu Linux machine, and I was able to print a null pointer:
#include <stdio.h>
int main() {
const char* ptr = NULL;
printf ("test %s\n", ptr);
}
The output is test (null).
When I run the same program in QNX I get:
Process 1302562 (a.out) terminated SIGSEGV code=1 fltno=11 ip=00000035fabe9c58 mapaddr=0000000000072c58 ref=0000000000000000
Memory fault (core dumped)
xmltest for Ubuntu successfully prints:
[pass] XMLDocument::Value() returns null? [(null)][(null)]
whereas QNX crashes becuase it cannot print null pointers.
@leethomason According to C11 and C99 standards published by ISO.
7.1.4 Use of library functions. Each of the following statements applies unless explicitly stated otherwise in the detailed descriptions that follow: If an argument to a function has an invalid value (such as a value outside the domain of the function, or a pointer outside the address space of the program, or a null pointer, or a pointer to non-modifiable storage when the corresponding parameter is not const-qualified) or a type (after promotion) not expected by a function with variable number of arguments, the behavior is undefined.
The behavior of passing null pointer to printf(%s, ptr) as a string has not been specified in C11, C99 and C++11 (gnu++11 might have specified it) standards. Hence if a null pointer might appear as an argument (string), it must be explicit checked before being dereferenced by printf(%s, ptr).
TLDR, there is an undefined behavior in the test program. The fix for QNX should be generalized.