1. Including same libraries two or more times
- Posted by ZNorQ Dec 09, 2014
- 1418 views
Hi,
Normally I split my code in several include-files, but this usually ends up in me having to re-include standard-euphoria (or other custom made files) include files when needed.
Example;
myOEMainProgram.exw
- Includes myOESubFileA.e -> which includes "std/sequences.e".
- Includes myOESubFileB.e -> which includes "std/sequences.e".
- Includes myOESubFileC.e -> which includes "std/sequences.e".
Here "std/sequences" is included three times; does this mean that all members (constants, enums, functions, etc) occupy memory three times, or are they included once, but are only visible to the files including them directly? Or something else?
Kenneth aka ZNorQ
2. Re: Including same libraries two or more times
- Posted by _tom (admin) Dec 09, 2014
- 1413 views
- An include file is physically "included" just once for any program.
- Duplicated includes are quietly ignored and do not add extra bloat to your program.
- Top level code within an include file will be executed the first time an include file is encountered (and then ignored for extra includes). For example puts(1, "hello" ) in an include file will be executed once.
The extra includes only make code available to the including file.
If you shroud, bind, or compile then any unused code is removed and the final program is a small as possible.
_tom
3. Re: Including same libraries two or more times
- Posted by ZNorQ Dec 10, 2014
- 1388 views
- An include file is physically "included" just once for any program.
- Duplicated includes are quietly ignored and do not add extra bloat to your program.
- Top level code within an include file will be executed the first time an include file is encountered (and then ignored for extra includes). For example puts(1, "hello" ) in an include file will be executed once.
The extra includes only make code available to the including file.
If you shroud, bind, or compile then any unused code is removed and the final program is a small as possible.
_tom
Great feedback _tom, much appreciated.
Regards, Kenneth aka ZNorQ.