FLTK logo

Re: [fltk.general] FLTK usage in passing pointers from file to file

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: FLTK usage in passing pointers from file to file Greg Ercolano Feb 23, 2021  
 

On 2/23/21 7:22 PM, John E. Kaye P.Eng. wrote:

I am a newbie here and have a simple problem that I don't seem to be able to resolve.
Given two(2) separate files that will be compiled and linked together.
In file 1 several windows are opened in the main().  All the windows are defined globally. Example 
Fl_Window *win;
Fl_Window *w1;
Fl_Window *w2;
I define and show() main window "win" and also define and show() "w1" in the main() program in File 1.  I define but hide() "w2" in File 1.
In File 2 I declare the following globally
extern Fl_Window *win;
extern Fl_Window *w1;
extern Fl_Window *w2;. 
Now in File 2 I wish to hide() "w1"[w1,hide()] and show() "w2"[w2.show()]
After a successful compile and link it gives a segmentation fault(core dumped) response?
Can anyone comment on how to globally pass defined windows from file to file?

    That should work, but if you're getting a coredump, sounds like maybe the variables
    haven't actually been initialized before they're used.. check to make sure the globals
    are being set before being used, and that the initialization is not somehow a local declaration
    that goes out of scope.

    If you're still not sure, show us a simple two file example that doesn't work but should,
    where one file has the main() and sets the variables, and calls functions in the other
    file that tries to use the variables. There may be something about what you're doing
    in the actual code.

--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/ed17c88c-2a87-3fbe-33ca-91dfd5232a16%40seriss.com.
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.