Problem with function HB_CompileFromBuf()

107 views
Skip to first unread message

WenSheng

unread,
Aug 18, 2021, 12:11:51 PM8/18/21
to Harbour Users
I have a question about the function HB_CompileFromBuf().
When I use the following code:
---------------
      local oHrb, cCode
      local cHBheaders1 := "~/hb32/include"
      local cHBheaders2 := "d:\hb32\include"
      cCode := MemoRead('debug.prg')
      oHrb = HB_CompileFromBuf( cCode, .T., "-m", "-q2", "-I" + cHBheaders1, "-I" + cHBheaders2, "-I" + hb_GetEnv( "HB_INCLUDE" ), hb_GetEnv( "HB_USER_PRGFLAGS "))
---------------
It displays the following error message:
Error COMPILER/1 Statement not allowed outside of procedure or function: line: 2

If I compile with harbour:
harbour -m debug.prg

The message is as follows:
Compiling'debug.prg'...
Lines 78, Functions/Procedures 2
Generating C source output to'debug.c'... Done.

If I change the parameters:
harbour -n debug.prg

The message is as follows:
Compiling'debug.prg'...
debug.prg(2) Error E0001 Statement not allowed outside of procedure or function
1 error

I have a question, does the function HB_CompileFromBuf() have preset parameters?
Is it'-n'? Can it be removed?

debug.prg

KennyOoi

unread,
Aug 19, 2021, 10:22:35 AM8/19/21
to Harbour Users

add an line before public z := "A" and return brfore func aaa()

proc debug()
...
.....
......
 outstd(e"</body>\n</html>\n")
func aaa()
return "aaa"

WenSheng

unread,
Aug 28, 2021, 11:14:34 PM8/28/21
to Harbour Users
solution: -n2

KennyOoi 在 2021年8月19日 星期四下午10:22:35 [UTC+8] 的信中寫道:
Reply all
Reply to author
Forward
0 new messages