LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

debug mode error messages without the IDE

We have a large CVI app running, that has been having some run-time errors (dereferencing null pointers, etc.) and we're running a debug build of the app without CVI, so as to get a CVI popup and error message whenever we get a run-time error.
 
We're curious if it's possible to explicitly use an error message in our code that can use the debug-build meta-data (i.e function names, variable names, source code line numbers, etc) at runtime.  I've seen some development environments that provide this - it's a way of allowing you to sprinkle somewhat generic error messages of your chosing throughout your code, but when the error occurs you not only get your error message, but it's localized by the meta-data available in the debug build.  The other choice is to hand-craft unique run-time error messages for localizing a run-time error.
 
Hayes
0 Kudos
Message 1 of 7
(3,645 Views)
Are you looking for the __FILE__ and __LINE__ macros?  These are ANSI C macros that expand to the filename and linenumber respectively.  LabWindows 6 and 7 support them.  I haven't tried with any other versions.  C99 defines a macro __func__ but it does not appear to be supported by LabWindows 7...   Is LabWindows 8 C99 compliant?
----
I am the founder of CnCSoftwareSolutions. When not cleaning up baby drool, I write about test data or work on Vision, a tool for understanding your test data. Visit me at www.cncsoftwaresolutions.com
0 Kudos
Message 2 of 7
(3,645 Views)
1. CVI 8 is not C99 compliant.

2. Using the __FILE__ and __LINE__ directives is a good idea. You can even use the Assert and AssertMsg macros that are defined in toolbox.h, which already do that for you.

3. Another alternative, if you are trying to debug a crash that is very hard to reproduce, is to generate a map file of your application (the option is in the Build>>Target Settings dialog). Then, when the crash does happen and it gives you the address of the last instruction that executed, you can look for this instruction in the code by examining the map file.

Luis
NI
Message 3 of 7
(3,638 Views)
You may find useful also the __FUNCTION__ macro, which expands to the function name.
 
Just my 2c... Smiley Happy


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 4 of 7
(3,632 Views)

Luis -

Thank you kindly - feel kind of sheepish I didn't realize that the line and file macros were C89 and supported by CVI.  It sure would be nice if we had the __func__ facility, but that's C99.

Do you know if NI ever intends to provide a C99 compliant internal compiler?  With NI's committment to ISO C for CVI, it would certainly seem to be a good idea and would be well received I think.

0 Kudos
Message 5 of 7
(3,630 Views)

Roberto -

Thanks, I was unaware of the __FUNCTION__ macro in CVI - it's not mentioned anywhere that I can see, it's not part of C89, and C99 uses __func__.

Hayes
0 Kudos
Message 6 of 7
(3,622 Views)
It's something we have considered, but we are essentially waiting to see if the adoption rate of C99 picks up. If not enough people request it, it's hard to justify us investing a lot of effort in it. But if it becomes widespread, then we will definitely support it in a future release.

Luis
0 Kudos
Message 7 of 7
(3,619 Views)