|
|
Thank you for your response and comment. I had declared the Window pointers Globally such as Fl_Window *w1, Fl_Window *w2 etc BUT defined them in the main() program in FILE 1 as Fl_Window w1(5,198,600,275,"Tester"), etc So when I now, as you counciled, declare all the Windows globally such as Fl_Window w1(5,198,600,275,"Tester"); Fl_Window w2(5,190,600,25,"Test Block"); etc
AND just declare the Windows in the second file FILE 2 as extern Fl_Window w1; extern Fl_Window w2; etc
The Windows for w1 and w2 show() or hide() correctly. However when the program ends or closes many lines of code are displayed starting with the statement *** Error in ./test1pgm : free(): invalid pointer: 0x0000000000000002320 followed by a back trace BUT, as I stated the program works Any further comments??
On Tuesday, February 23, 2021 at 9:59:52 PM UTC-6 er...@seriss.com wrote:
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/8b448fd8-0827-4209-88f2-77766774e68bn%40googlegroups.com.
[ Direct Link to Message ] | |
|
| |