From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
11-27-2017 06:42 PM
This warning seems incorrect in this case:
#include "stdio.h" union act_val{ double a; int b; }; void thing2(union act_val av) { printf("%d\n", av.b); } int main(int argc, char const *argv[]) { union act_val av; av.b = 1; thing2(av); return 0; }
Variable av is uninitialized when used here, at the thing2 call. The warning goes away if the 'a' field is an 'int'. I suppose it is warning me that not all the bytes of the union are being initialised, as double is larger than int here. It seems like half the reason for a union is to be able to deal with a specific field at a time.
Of course I can work around the warning by initialising the 'a' field, I do not like the initialise variables with false values however as it stops genuine warnings and valgrind errors.
11-29-2017 07:59 AM
Hi evanb,
It seems that LabWindows/CVI performs only minimal checks for union type variables. If a union contains pointers, arrays, or structs, LabWindows/CVI does not maintain user protection information for those objects.
I found that in this link http://zone.ni.com/reference/en-XX/help/370051M-01/cvi/programmerref/unions/
Have a great day.
11-29-2017 03:50 PM
Hello,
Thanks for the reference, but it does not seem relevant here. My union does not contain a pointer, array, or struct. It is not obvious, but that doc might be referencing run time, while I am talking about compile time. I was also under the impression that cvi used clang to compile, clang does not give the same warning, even with -Weverything. The doc is dated 2008, I am using CVI 2017.
Thanks
12-01-2017 08:31 AM
Hi,
Also, this is the documentation that you can find on CVI Help.
I want to mention this forum, https://forums.ni.com/t5/LabWindows-CVI-Idea-Exchange/idb-p/cviideas normally R&D check out this if you have great ideas or thing that you may want to change on CVI.
I found this about clang, https://forums.ni.com/t5/Community-Documents/How-to-build-and-integrate-lastest-clang-compiler-to-CV...
On the readme file of CVI 2017,
The following components and features were deprecated in LabWindows/CVI 2017: