I have not tested to see if private functions and var not used in the main bas vs. included in a file operate any differently, but I would assume not because as dodicat stated:
dodicat wrote:#include "somefile" is a shortcut to copy and paste in Freebasic.
Imortis wrote:I have not tested to see if private functions and var not used in the main bas vs. included in a file operate any differently, but I would assume not because as dodicat stated:
dodicat wrote:#include "somefile" is a shortcut to copy and paste in Freebasic.
It doesn't matter if the extension is .bas, .inc, .txt or wathever, or if you use one file or a dozen. The keys are that they must contain source code and that the procedures and/or methods will be prefixed as private. This technique can't be used with DLLs or libraries, only with source code.
As I have never used private in this manner (only used the access modifier for UDTs/Classes), I was not sure what it did here. It's whole purpose is to mark a procedure as internally linked. This is why the compiler is able to say for sure it is not needed. If nothing in the main program uses it, it is not used at all.
If we are talking include files, then private functions are in the same program as running code, and thus accessible.
If the private functions are in a .bas file and compiled with -lib then the functions are not accessible by loading the library and using function declarations in the normal way, or any other way as far as I can see.
For creating a .dll file of private functions, the compiler won't allow the keyword export at a private function, so a .dll of private functions will not compile.
These are the three options I have tried out anyway.
Also
A private member sub of a udt in the static library can be accessed as though the word private was not used.
The way I use this feature is the same that I used with PowerBASIC. I have built a framework with many classes and wrapper procedures using include files, declaring all the procedures and methods as private. When I need the functionality provided by some of the include files, I simply use #include "xxx.inc". The main advantages of using this technique is dead code removal, conditional compilation when needed and much less work to maintain the code.