LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

how to force struct popups to work all of the time in CVI 8

Does anyone know how to force the completion popups to appear for structure elements in CVI 8.  I have a project where the popups aren't coming up reliably for a few structs when I use '->' or '.' notation anymore.  Have rebuilt the project in both debug and release modes, recomplied in both, rebooted way too many times, etc.  This is EXTREMELY annoying--I didn't realize how spoiled I was... Smiley Sad
 
What is strange is that in certain .c files in this project, the struct popups work like normal.  In other .c files (which by the way, have successfully compiled without error or informational messages) that same struct won't offer the popups.  My structs are defined in a .h file that is #define'd in a top-level .h file.  The top-level .h file is included in all of the .c files in this project.  But since the struct popups work in some of the project's .c files, the definition of the structs in a lower-level .h file should clearly have nothing to do with it.  I got tired of using extern declarations all over the place, so I moved most declarations to the .h.  Clearly I may need to go back and put the extern's back in if I want to have the popups available to me.  Does anyone have any other ideas to try first?
 
Thanx,
Orlan
0 Kudos
Message 1 of 8
(4,108 Views)
Hi Orlan,
 
This is puzzling!  Here are a few things you could try: 
 
1.  Deleting the CVI build output files and rebuilding the project (the popups work only in debug mode)
2.  Make sure your variables have the right type (for example, if some are void* instead of struct x*, CVI won't know what the members are).
3.  I'm not sure if something like ((struct X*)callbackData->foo will work.  You could try declaring a local variable struct and then using x->foo.
 
I hope this makes some difference!  Let us know how it goes.
Megan B.
Applications Engineer
National Instruments
Message 2 of 8
(4,067 Views)

Hi Megan,

  One of my primary structs was defined in foo1.h and the other primary struct was defined in foo2.h.  I have two source files, foo1.c and foo2.c that both have #include's for both foo1.h and foo2.h.  I declared a global variable of pointer to one of the primary structs and initialized it to NULL in foo1.c.  Then I declared a global variable of pointer to the other struct and initialized it to NULL in foo2.c.  I needed to access the global pointer to the struct from foo1.c in a function in the foo2.c file, so I declared an extern reference in foo2.c within that function.  It worked fine for a while and then all struct popups in foo2.c just suddenly stopped working altogether.  The popups in foo1.c always worked.

  Just today, I moved the declaration for the global pointers into the header files and now I initialize them both in another source file.  All of the struct popups are working again in all of the source files.  I noticed the little delay while the IDE looked up the popup information when foo2.c was misbehaving, but the popup never appeared.  Now it is appearing.  Normally I use local extern references to variables from other source files and this time I used a global extern reference instead.  Perhaps that played into the problem.  I don't have time to re-create it, but if I stumble across it again, I may dig in and try to isolate it.

  I have also seen one or two situations where I updated a struct definition in a header file (added or removed a struct element) and following recompile sometimes the struct popup didn't always reflect the latest changes.  I had one source file in this same project where that was also the case but it hasn't happened in a week.  Maybe the IDE was mad at me?  😆

Thanx,

Orlan

0 Kudos
Message 3 of 8
(4,045 Views)

Hi Orlan,

Well I'm very glad the popups are working again, but it is somewhat mysterious.  I'd like to have a better solution than suggesting that you avoid irritating the IDE 🙂 but I haven't come across any similar issues.  If you do find any other information on reproducing this, please let us know!

Happy coding,
Megan B.
Applications Engineer
National Instruments

0 Kudos
Message 4 of 8
(4,019 Views)

Well,

  ...The IDE is mad at me again Smiley Indifferent  Actually, it had absolutely nothing to do with my re-arranging the structs in the header files earlier this week.  There is definitely a bug in the IDE.  I don't know what it takes to cause the popups to not appear yet, but I do know what does and what does not work to get them started again.

Of no use: recompiling the source file with the malfunctioning popup (Ctrl-K), making the entire build (Ctrl-M), marking the entire project for compilation and then making the build, switching between debug and release builds and then making the build, restarting CVI and then compiling, restarting CVI and making the entire build, deleting the build directory in the project folder and then recompiling the source file with the malfuncitoning popup

Only known resolution: deleting the build directory in the project folder and then making the build (will automatically detect the build directory is missing and will mark the entire project for compilation)

  Again, this does not happen to all structs in the source file with the malfunctioning struct popups.  But following the resolution outlined above, the popups immediately start working again.  Smiley Happy

Orlan

0 Kudos
Message 5 of 8
(4,002 Views)

Megan,

  I forgot to add recognition for you in my post, but actually you suggested the delete option in your item #1.  That that did the trick.  I still would like to figure out what gets it confused--at least if there is something that I can do to trigger the behavior.  That might help with a resolution.

Thanx,

Orlan

0 Kudos
Message 6 of 8
(3,996 Views)

#include <ansi_c.h>
#include <cvirte.h>

struct str_foo {
 int i_test;
} gstr_foo[100];

struct str_foo2 {
 int i_test2;
} *gstr_foo2;

int main (int argc, char *argv[]) {
 if (InitCVIRTE (0, argv, 0) == 0) return -1;    /* out of memory */
 
 gstr_foo2 = calloc(100, sizeof(struct str_foo));
 
// gstr_foo[0].   //popup shows: i_test
// gstr_foo2->    //popup shows: i_test2
// gstr_foo[gstr_foo2-> //popup shows: gstr_foo, gstr_foo2
 
 free(gstr_foo2);
 
 return 0;
}

-----------------------

  Compile this file first.  Then uncomment the three gstr_foo lines, but do not recompile.  Now position your cursor after the "." operator in the first previously commented gstr_foo.  Press Ctrl+Space and it will complete 'i_test'.  You can delete and re-enter the "." and the popup will alternatively appear with 'i_test'.  Whatever, same thing.  Now do it for gstr_foo2.  It shows 'i_test2' as expected.  But when you try the second gstr_foo, which has pointer notation inside of the array notation, the popup misbehaves.  It should be showing i_test2 since this is the only available struct element in gstr_foo2.  Notice the popup is at the beginning of the line, instead of at the end of "->" (where it should be) and that if you select something in the popup it either does nothing or it rewrites the beginning of the line.

  Personally, I think this bug is what starts the whole mess for me.  When I loose my popups, it tends to allow the outer struct to continue to show popups and the inner struct will not show popups anymore.  I could not get this simple project to lose popups altogether, but it does show some misbehavior.  It is a bit more complicated in my real code, something like: gstr_foo->widget.status = gstr_foo2[gstr_foo->thingy.doohickey].status;  I loose popups for gstr_foo but popups for gstr_foo2 still work.  And now the doggone 'delete the build directory' approach isn't even working anymore.  Smiley Mad

Orlan

0 Kudos
Message 7 of 8
(3,990 Views)

Hi Orlan,

You are indeed correct, this is funny behavior.  Thanks so much for posting such a complete method for reproducing this error.  I have reported this to R&D (#3WKCASXE) for further investigation. I'm sorry for the inconvenience and I will certainly post if I hear anything back quickly.

Thanks for the feedback!
Megan B.
Applications Engineer
National Instruments

0 Kudos
Message 8 of 8
(3,963 Views)