1. Including same libraries two or more times

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

new topic     » topic index » view message » categorize

2. Re: Including same libraries two or more times

  • 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

new topic     » goto parent     » topic index » view message » categorize

3. Re: Including same libraries two or more times

_tom said...
  • 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.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu