Re: EuGTK - GtkDrawingArea
- Posted by mattlewis (admin) Oct 11, 2010
- 1242 views
I'm getting an error in t_safe.e (interpreted) and t_literals.e (translating), but I didn't think it was related to that issue.
Yes they are. I got around the safe.e by moving the include files around, but really that is not the best way. A coder should not have to arrange the include files in a particular order just to avoid crashing the application.
Well, yes and no. I agree that the user of a library shouldn't have to rearrange include order, but in this case, there's not really another alternative. It's simply a case of when certain code executes. One statement must be either before or after another. And if statement B must follow statement A, but does not, you'll get an error, like we had here.
Here was the basic issue:
-- file_a.e include file_b.e export constant foo = call_some_function() -- ....code... -- file_b.e include file_a.e ? foo
In this case, if your code includes file_b.e first, it should work, because foo should be initialized before we try to print it. However, if you include file_a.e first, before foo can be initialized, file_b.e is included, and it attempts to use foo.
To fix this:
-- file_a.e export constant foo = call_some_function() include file_b.e -- ....code... -- file_b.e include file_a.e ? foo
...and now, foo is definitely initialized prior to being used in file_b.e, regardless of how those files were included into a program. So I think that as a general practice, top level initializations should be done as soon as possible, and with minimum includes preceding them in the file.
Matt