Announcement

Collapse
No announcement yet.

INC files and size optimization..

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • INC files and size optimization..

    A silly tip that may save a few KB's. If you include COMDLG32.INC,
    you also get the code for all Common Dialogs baked into your program.
    I looked at COMMCTRL.INC and decided to test the same kind of
    "$IF NOT %DEF" kind of system on COMDLG32.INC.

    By wrapping each Dialog procedure with $IF NOT %DEF() and $ENDIF,
    plus using a table like follows, I actually managed to save almost
    10KB in a small program that only needed the open/save dialogs. Now
    all I have to do, is to remember including this table before the line
    that says #INCLUDE "COMDLG32.INC" and uncomment what I want to use.
    Example:
    Code:
    'In program:
    ' %NOCOLOR       = 1
    ' %NOFINDREPLACE = 1
    ' %NOFONT        = 1
    ' %NOPRINT       = 1
      %NOOPENSAVE    = 1
    #INCLUDE "COMDLG32.INC"
    'in COMDLG32.INC, wrap individual dialog's code with (adjust accordingly):
    Code:
     
    $IF NOT %DEF(%NOPRINT)
    ' Printer dialog's code..
    $ENDIF
     
    $IF NOT %DEF(%NOFONT)
    ' Font dialog's code..
    $ENDIF
    etc..

    ------------------

  • #2
    Personally, I prefer to copy & paste (into my apps) just the declarations I need. This way, if the distribution INC files change radically, my apps will still compile. I usually create a "private" INC file for this task.

    This can be a bit of work, but it eliminates 100% of the unwanted subs/functions from the code, and can be interesting to see the true number of declarations, equates and structures a program is using!


    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment


    • #3
      The common controls inc is using a lot of code in the exe.
      Even with almost any option set (excluding sections)
      Maybe seperate inc's are better (For the next version i mean)
      Personally, i have nothing against multiple inc's.
      I'm against copying parts each time i need it.

      I think the default include files are very important.
      Not just an additional benefit created by PB.

      Thanks,



      ------------------
      [email protected]
      hellobasic

      Comment


      • #4
        Personally, I love the large INC files we use - they make my life *much* easier!

        I can get most test apps up and running with only a couple of #INCLUDE lines, and compile time is barely noticeable..

        However, how you guys/gals reconstruct the INC files for your own taste is up to you - PowerBASIC provide the INC files purely as a courtesy!

        As I see it, reducing the final EXE/DLL size is one of the very last things to do to a project/application, and that is when you can paste in just the declarations and subs/functions from the INC files, as you require. No excess baggage for shipping, and less hassle remembering to #INCLUDE loads of files during development.

        My $0.02...


        ------------------
        Lance
        PowerBASIC Support
        mailto:[email protected][email protected]</A>
        Lance
        mailto:[email protected]

        Comment


        • #5
          I actually hadn't thought about this before, but looked at a small
          program in HEX and found a lot of things I knew I never had included
          myself. Excluding most of the common dialogs, took down the file size
          from 42 KB to just above 32. Not much in a sea of Giga bytes, but
          still worth considering, since every little byte counts up..

          One thing I have been wondering about, is why everybody is crying
          for visual stuff, when what we really need is a better editor. The
          editor is the base for it all. A good editor can be made to handle
          projects, version info, automatic check and compiling of resource
          files, plus automatic handling of a library of include files, etc.

          If PB had released the current editor as open source, I'm sure we
          would have seen some terrific solutions that would have brought the
          language many steps up on the ladder. The compiler already is extremely
          good, now all we really need is an editor that can wrap some
          advanced, "automatic" functionality around it..


          ------------------

          Comment


          • #6
            Several of the "*.inc" files have procedures in them. While these are nice, it would be a lot nicer if PB documented the functions they add with at least a DECLARE statement.

            Some of the sample code just uses these included functions, relying solely on the fact the functions are defined prior to their use.


            MCM
            Michael Mattias
            Tal Systems Inc. (retired)
            Racine WI USA
            [email protected]
            http://www.talsystems.com

            Comment

            Working...
            X