LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

array size not known message

I am using LabWindows/CVI 7.1.  When debugging and trying to display the contents of an array I often get the message: "Size not known.  Estimate the number of elements before editing."  I usually see this on a array I have allocated dynamically.  I am wondering what causes this condition and if anything can be done to remedy it.  It's frustrating because I know the number of elements, otherwise I couldn't allocate it, yet somehow CVI doesn't think it knows the number of elements all of a sudden.  I need to be able to use CVI's built-in "Graphical Array View" to quickly view the array, but I can't with this limitation.
0 Kudos
Message 1 of 10
(4,436 Views)
Hi Snood1,
 
Thank you for your post.  I am checking into this, and will have more information tomorrow.
Cheers,

David Goldberg
National Instruments
Software R&D
0 Kudos
Message 2 of 10
(4,405 Views)
Hi Snood1,
 
I dynamically created an array in CVI 7.1:
 
       wave = malloc(100 * sizeof (double));
        for (i=0;i<COUNT;i++)
            wave[i] = (double)rand();
 
and could not get the message you are getting.  Before the malloc call is executed, the Value in the Watch box is NULL, and one cannot select the Graphical Array View.  After the malloc executes, the Value appears, and Graphical Array View works fine.
 
Would you please post a screenshot and paste a code snippet?  Also, when this message appears, can you provide it with an estimate and the Graphical Array View will appears?
Cheers,

David Goldberg
National Instruments
Software R&D
0 Kudos
Message 3 of 10
(4,382 Views)
David,

It may be worth pointing out that I am debugging a dll rather than a standalone exe.

-Joel
0 Kudos
Message 4 of 10
(4,356 Views)

Hi Joel,

I could not reproduce the error adding the above array allocation to the Scope and Usescope example.  Are you calling a CVI DLL?  Can you post a code snippet, or the files so that I can reproduce the error?  Also, when this message appears, can you provide it with an estimate and the Graphical Array View will appear?

Cheers,

David Goldberg
National Instruments
Software R&D
0 Kudos
Message 5 of 10
(4,331 Views)
I have provided a better example of what our code does.  Please build a debuggable DLL with the included c file and call it with the included seq.  Let me know if I can answer questions about the example.

Thanks,
Joel
0 Kudos
Message 6 of 10
(4,217 Views)
Hi Joel,
 
As you suspected, the problem is with the void pointers - Graphical Array View won't work with them.  This is because the compiler doesn't know what type of data it is pointing to, nor the size of the array.  This information is not included in a void pointer.  If you change it to double pointer, you will see that it works. 
 
Notice that the only reason that YGraphPopup works is that we specify the number of points and the type of data in the parameters.  There is no way to specify this to Graphical Array View.  If you would like, you can make a product suggestion for this at ://sine.ni.com/apps/utf8/nicc.call_me.
Cheers,

David Goldberg
National Instruments
Software R&D
0 Kudos
Message 7 of 10
(4,183 Views)
David,

Thanks for the help.  Regarding the void pointers, my calling function, AllocateMemoryExample, declares the adSampleArray to be type double pointer.  It's only when it is passed into GetSingleTestStandParameter that it is cast to (void**).  So inside AllocateMemoryExample, shouldn't adSampleArray continue to be interpreted as type double because it was declared so?  This is not the behavior, obviously, but it seems to me as though it should be.

Additionally, when you do try to view the array contents in the variable display window you get the message "Size not known.  Estimate the number of elements before editing."  This message seems misleading to me because it implies there is somewhere in the debugger where you can input the number of elements and then be able to view your array contents.  I don't think such a capability exists, so what is this message really saying?

Thanks,
Joel
0 Kudos
Message 8 of 10
(4,167 Views)
Hi Snood,

The "Size not known. Estimate the number of elements before editing." error message tells the user that we cannot show an array of indeterminate size.  So you need to actually set the array length/size in the Options >> Estimate Number of Elements menu. In your case, as soon as you finish the GetSingleTestStandParameter function and you return back to the AllocateMemoryExample function (by stepping into via F8 during debug;  See attached "Before.jpg"), immediately select the adSampleArray in the Variables windows and then select Options >> Estimate Number of Elements and in your case, type in 5. You can now view this variable via the Graphical Array View. See attached "Menu & Selection.jpg" and "After.jpg" snapshots.

In reference to your first question, you are performing all memory allocations in your GetSingleTestStand Parameter function on a type void **.  Void pointers simply contain an address with no knowledge about what it points to (data types and sizes). This in term doesn't allow the compiler to know about the size of an array unless you tell it to which is what I described in the first part.

Dealing with void ** can be a little tricky sometimes but if you use the Estimate Number of Elements option, you should be good to go. 

Best Regards,
Jonathan N.
National Instruments
Download All
Message 9 of 10
(4,148 Views)
Jonathan,

I was able to try this with success.  This will make my debugging much easier.  Thanks for the help.

-Joel
0 Kudos
Message 10 of 10
(4,126 Views)