Just gave jaPBe a small try, using the test files as given in earlier post.
Using the cutter plugin ..
Compiling to executable the MyTestProc2() is still added to final executable even though it isn't being called.
-----
As said in previous post, I think I'll just have to comment out the test code when not testing or have it in its own file.
Again thanks to all.
Test code in includes
Re: Test code in includes
%101010 = $2A = 42
Re: Test code in includes
Does it really work ?Bisonte wrote:If you want "not included" unused procedures...
jaPBe has a "Cutter" Plugin, that shredder the code to one big file with only the used procedures...
(for the final compile its very useful...)
I wanted to make something of that kind myself but I given up.
http://www.purebasic.fr/english/viewtop ... 54#p369254
Just think of using one or more macros to build up a procedure body, or a procedure to be excluded by some conditional compilation. Does "cutter" works as expected here ? I doubt it.
"Have you tried turning it off and on again ?"
Re: Test code in includes
The body of the procedure (the code) is not included, only its text (string) in the data section.Perkin wrote: The resultant main project code runs as it should, but viewing the exe in a hex viewer, it looks like the MyTestProc2 is still included, even though it isn't called directly - only from the now not included test code.
This is because the pb compiler generate all the code/data for all the procedures inside macros, and then SOME of them are never expanded.
http://www.purebasic.fr/english/viewtop ... 45#p318245
Code: Select all
;
; #INCLUDED=1
;
; Procedure MyTestProc()
macro MP0{
_Procedure0:
PS0=4
; MessageRequester("Hey","I am here!")
PUSH dword _S1
PUSH dword _S2
CALL _PB_MessageRequester@8
; EndProcedure
XOR eax,eax
_EndProcedure1:
RET
}
;
; Procedure MyTestProc2()
macro MP2{
_Procedure2:
PS2=4
; MessageRequester("Hey","I am here as well!")
PUSH dword _S3
PUSH dword _S2
CALL _PB_MessageRequester@8
; EndProcedure
XOR eax,eax
_EndProcedure3:
RET
}
;
; CompilerIf Defined(INCLUDED,#PB_Constant)=0
;
;
; MyTestProc()
CALL _Procedure0
_PB_EOP_NoValue:
PUSH dword 0
_PB_EOP:
CALL _PB_EndFunctions
PUSH dword [PB_MemoryBase]
CALL _HeapDestroy@4
CALL _ExitProcess@4
_PB_EndFunctions:
RET
;
MP0
;
section '.data' data readable writeable
;
_PB_DataSection:
_PB_OpenGLSubsystem: db 0
pb_public PB_DEBUGGER_LineNumber
dd -1
pb_public PB_DEBUGGER_IncludedFiles
dd 0
pb_public PB_DEBUGGER_FileName
db 0
_PB_ExecutableType: dd 0
public _SYS_StaticStringStart
_SYS_StaticStringStart:
_S1: db "I am here!",0
_S3: db "I am here as well!",0
_S2: db "Hey",0
pb_public PB_NullString
db 0
public _SYS_StaticStringEnd
_SYS_StaticStringEnd:
align 4
align 4
s_s:
dd 0
dd -1
align 4
;
section '.bss' readable writeable
_PB_BSSSection:
align 4
;
I_BSSStart:
_PB_MemoryBase:
PB_MemoryBase: rd 1
_PB_Instance:
PB_Instance: rd 1
;
align 4
PB_DataPointer rd 1
align 4
align 4
align 4
align 4
I_BSSEnd:
section '.data' data readable writeable
SYS_EndDataSection:
"Have you tried turning it off and on again ?"
Re: Test code in includes
I think so... I tried it with the jaPBe source itself and it works there... only one big file and a lot of procedures are notluis wrote:Does it really work ?Bisonte wrote:If you want "not included" unused procedures...
jaPBe has a "Cutter" Plugin, that shredder the code to one big file with only the used procedures...
(for the final compile its very useful...)
I wanted to make something of that kind myself but I given up.
http://www.purebasic.fr/english/viewtop ... 54#p369254
Just think of using one or more macros to build up a procedure body, or a procedure to be excluded by some conditional compilation. Does "cutter" works as expected here ? I doubt it.
longer in the source.
Re: Test code in includes
So it's only the string data that's added?luis wrote:The body of the procedure (the code) is not included, only its text (string) in the data section.Perkin wrote: The resultant main project code runs as it should, but viewing the exe in a hex viewer, it looks like the MyTestProc2 is still included, even though it isn't called directly - only from the now not included test code.
This is because the pb compiler generate all the code/data for all the procedures inside macros, and then SOME of them are never expanded.
I think that might be alright, I'll have to check through some of them to see.
Thanks.
%101010 = $2A = 42
Re: Test code in includes
A simple example, you can make it more convoluted and find many other "hard" casesBisonte wrote:I think so... I tried it with the jaPBe source itself and it works there... only one big file and a lot of procedures are notluis wrote: Does it really work ?
I wanted to make something of that kind myself but I given up.
http://www.purebasic.fr/english/viewtop ... 54#p369254
Just think of using one or more macros to build up a procedure body, or a procedure to be excluded by some conditional compilation. Does "cutter" works as expected here ? I doubt it.
longer in the source.
Code: Select all
; unused1()
Macro genproc_start()
Procedure unused1()
Debug "unused1()"
EndMacro
Macro genproc_end()
ProcedureReturn
EndProcedure
EndMacro
genproc_start()
genproc_end()
; unused2()
Procedure unused2()
unused1()
EndProcedure
; used1()
Procedure used1()
Debug "used1()"
ProcedureReturn
EndProcedure
Procedure Main()
used1()
EndProcedure
Main()
Not until... http://www.purebasic.fr/english/viewtop ... =3&t=40658
"Have you tried turning it off and on again ?"
Re: Test code in includes
That looks like it would be good.luis wrote:Not until... http://www.purebasic.fr/english/viewtop ... =3&t=40658
%101010 = $2A = 42
Re: Test code in includes
Two notes:
1. Trimming... look around, several tools were at one time posted. I hate the missing includes myself, so I added a 'trimming' version to CodeCaddy as well.
2. Includes... yeah, I would love to have a constant that would indicate if the include was executed by itself, or if it was included by another program. It would make it so much easier to maintain includes and quickly test them for bugs. I'd love it.
1. Trimming... look around, several tools were at one time posted. I hate the missing includes myself, so I added a 'trimming' version to CodeCaddy as well.
2. Includes... yeah, I would love to have a constant that would indicate if the include was executed by itself, or if it was included by another program. It would make it so much easier to maintain includes and quickly test them for bugs. I'd love it.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB - upgrade incoming...)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
-
Sirius-2337
- User

- Posts: 59
- Joined: Sat May 14, 2011 10:39 am
Re: Test code in includes
You can do this by adding a Custom Constant in Compiler Options.I would love to have a constant that would indicate if the include was executed by itself, or if it was included by another program.
For example add "#IsExecutedByItself = 1". Then you can check whether the Constant is defined or not.
It won't be defined if the code is included by another code.


