Author Topic: Question about usage of ".h" compiler files  (Read 3367 times)

0 Members and 1 Guest are viewing this topic.

Offline doppler

  • Forum Regular
  • Posts: 241
    • View Profile
Question about usage of ".h" compiler files
« on: August 08, 2019, 08:18:31 am »
Is the declare usage rigid ?

Such as :

DECLARE LIBRARY "Test1"
    FUNCTION CInp (BYVAL Toggle AS LONG) 'Get the INP scan code for keypresses from the console
END DECLARE

If I only wanted to use the CInp function inside "test1."  Or do I need to declare all functions ?
And is there an order you need to declare them ?  re: Out of order from "test1.h" file functions. Using
the third function inside but it's the first declare to the .bas program.

Microsoft uses internally shortcuts to the DLL libraries.  Speeding up calls to used functions.
Many are undocumented, but people find these things anyway.  Wondering because some programmers
got burned when MS, changed things.  Making calls within a DLL to the wrong function (use to be right
prior to MS changing things.)


Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Question about usage of ".h" compiler files
« Reply #1 on: August 08, 2019, 11:35:03 am »
Feel free to declare only the ones you need.  Heck, even remove the others from the Test1.h file, if you want to, so they won’t bloat your exe size any more than necessary.  Order in the library doesn’t matter; just so long as they’re declared in your program.

Think of them like you would SUB/FUNCTION in QB45.  QBASIC and QB45 used to DECLARE (sub/function name) at the top of your program — IF they were used in the program.  You could write a dozen routines, but if they were never called, then you never had to declare them for use.

QB64 DECLARE LIBRARY works in a similar manner.  You only need to declare the external routines you want to use.  The rest, you can just overlook and forget about.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline doppler

  • Forum Regular
  • Posts: 241
    • View Profile
Re: Question about usage of ".h" compiler files
« Reply #2 on: August 08, 2019, 03:00:25 pm »
What I thought it was about.  I am not a big C guy.  I know why ".h" files exist.
I get lost in compiler directives, implied includes and defined includes.

Funny how I can do assembler, pseudo high level.  But then C throws me.

Thanks