* bin/check.hb
* config/*/*.mk
* contrib/gtwvg/wvgwing.c
* contrib/hbcomm/comm.prg
* contrib/hbfbird/tfirebrd.prg
* contrib/hbfimage/fi_wrp.c
* contrib/hbformat/hbfmtcls.prg
* contrib/hbformat/utils/hbformat.prg
* contrib/hbhttpd/core.prg
* contrib/hbnetio/utils/hbnetio/hbnetio.prg
* contrib/hbnetio/utils/hbnetio/netiomgm.hb
* contrib/hbsqlit3/hdbc.prg
* contrib/hbwin/win_bmp.c
* contrib/xhb/htmutil.prg
* contrib/xhb/thtm.prg
* contrib/xhb/xhbarr.c
* contrib/xhb/xhbtedit.prg
* ChangeLog.txt
* debian/control
* debian/copyright
* doc/*.txt
* LICENSE.txt
* package/harbour.spec
* README.md
* src/compiler/hbusage.c
* src/pp/hbpp.c
* src/rtl/memoedit.prg
* src/rtl/teditor.prg
* src/rtl/tget.prg
* src/rtl/version.c
* utils/hbi18n/hbi18n.prg
* utils/hbmk2/hbmk2.prg
* utils/hbmk2/po/hbmk2.hu.po
* utils/hbtest/hbtest.prg
* sync with 3.4 fork (no change in functionality)
CC3 -> CC4 license, copyright banners, some strings, minor
code changes, doc folder, TOFIX -> FIXME
197 lines
5.4 KiB
Plaintext
197 lines
5.4 KiB
Plaintext
INTRODUCTION
|
|
============
|
|
This file explains what is and how to use the #pragma directive
|
|
with Harbour. Primarily, it gives you control over the compiler's
|
|
command-line switches within your source code.
|
|
|
|
|
|
WHAT IS
|
|
=======
|
|
The #pragma is a directive used inside the source code in many compilers
|
|
to change the behavior of the compiler at compile time.
|
|
|
|
|
|
USAGE
|
|
=====
|
|
Currently the #pragma directive can be used in two ways: the switch mode
|
|
and the command mode.
|
|
|
|
The syntax is: #pragma <Expression>[=On/Off] or
|
|
#pragma -CompilerFlag[+|-]
|
|
|
|
You can use both modes mixed in the same module and upper/lower case
|
|
without worry.
|
|
|
|
To enable or disable a command or a switch you simply do:
|
|
|
|
* Command mode Switch mode
|
|
--------------------------------------------------------------
|
|
* #pragma <CommandName>=On/Off #pragma /<SwitchName>+/-
|
|
|
|
Example: #pragma DebugInfo=Off /* Suppress debug info */
|
|
#pragma /B+ /* Add debug info from here */
|
|
|
|
|
|
IMPLEMENTATION
|
|
==============
|
|
|
|
This is the list of the supported commands and switches:
|
|
|
|
* Command Switch
|
|
-----------------------------------------------
|
|
* AUTOMEMVAR =<On/Off> -a<+/->
|
|
* DEBUGINFO =<On/Off> -b<+/->
|
|
* DYNAMICMEMVAR =<On/Off> -v<+/->
|
|
* ENABLEWARNINGS =<On/Off> -w<+/->
|
|
* ESCAPEDSTRINGS =<On/Off>
|
|
* EXITSEVERITY =<nLevel> -es<nLevel>
|
|
* LINENUMBER =<On/Off> -l<+/->
|
|
* NOSTARTPROC =<nLevel> -n<nLevel> (read-only)
|
|
* PREPROCESSING =<On/Off> -p<+/->
|
|
* SHORTCUT =<On/Off> -z<+/->
|
|
* TEXTHIDDEN =<On/Off>
|
|
* TRACE =<On/Off> -p+
|
|
* WARNINGLEVEL =<nLevel> -w<nLevel>
|
|
|
|
The switches have the same behavior as the corresponding compiler ones
|
|
and the commands are synonyms for the switches.
|
|
|
|
* TRACEPRAGMAS
|
|
This command shows pragma activity at compile time when enabled.
|
|
|
|
NOTE: You can use the abbreviated command mode by typing only the
|
|
first eight chars.
|
|
|
|
|
|
NOTES
|
|
=====
|
|
This directive is not supported in the standalone version of the Harbour
|
|
preprocessor.
|
|
|
|
|
|
EXAMPLES
|
|
========
|
|
|
|
#pragma linenumber=off
|
|
/* #pragma -l */
|
|
|
|
This is the same as calling Harbour with the -l switch in the command-line,
|
|
but with the great benefit that if you forgot to pass the switch, it will
|
|
be used anyway because it is included inside the source.
|
|
|
|
===========
|
|
1999-12-01
|
|
Regards,
|
|
Jose Lalin <dezac@corevia.com>
|
|
|
|
|
|
SPECIAL PRAGMAS
|
|
===============
|
|
These pragmas allows to control the processing of PRG source within
|
|
the preprocessor. The special handling is done with a text enclosed
|
|
between the '#pragma <type>' and '#pragma __endtext'
|
|
|
|
#pragma __text
|
|
--------------
|
|
Syntax:
|
|
#pragma __text '|' [LineOutputCode] '|' [FinallyCode] '|' [StartupCode]
|
|
|
|
Every line of text is stringified using '[' and ']' markers and is
|
|
passed to 'LineOutputCode' using C '%s' formatting code. The result
|
|
text is passed further to the syntax analyzer. The 'StartupCode'
|
|
is returned at the very beginning of processing. The 'FinallyCode'
|
|
is returned at the end. If 'LineOutputCode' is omitted then all
|
|
lines are ignored.
|
|
|
|
For example, this pragma is used to implement TEXT/ENDTEXT command
|
|
|
|
#command TEXT => #pragma __text|QOut(%s)|QQOut()
|
|
#command TEXT TO PRINTER => ;
|
|
#pragma __text|QOut(%s)|__TextRestore()|__TextSave("PRINTER")
|
|
#command TEXT TO FILE <file> => ;
|
|
#pragma __text|QOut(%s)|__TextRestore()|__TextSave(<"file">)
|
|
|
|
|
|
?
|
|
#xcommand TEXT INTO <v> => #pragma __text|<v>+=%s+hb_eol();<v>:=""
|
|
?
|
|
|
|
#pragma __stream
|
|
----------------
|
|
Syntax:
|
|
#pragma __stream '|' [JoinLineCode] '|' [EndingCode] '|' [StartingCode]
|
|
|
|
All lines are joined together. The result text is stringified and is
|
|
appended to 'StartingCode'. Finally the 'EndingCode' is appended.
|
|
The resulting text is returned for further syntax analysis.
|
|
|
|
For example:
|
|
|
|
#command TEXT TO VAR <var> => ;
|
|
#pragma __stream|%s||<var>:=
|
|
|
|
|
|
?
|
|
#xcommand TEXT TO VAR <var> => #pragma __stream|<var>:=%s
|
|
?
|
|
|
|
TEXT TO VAR v
|
|
This is 'example' text with ''""[] embedded
|
|
ENDTEXT
|
|
|
|
The above example is preprocessed into:
|
|
v:=[This is 'example' text with ''""[] embedded]
|
|
|
|
#pragma __cstream
|
|
----------------
|
|
Syntax:
|
|
#pragma __cstream '|' [JoinLineCode] '|' [EndingCode] '|' [StartingCode]
|
|
|
|
This is similar to '#pragma __stream' with the additional conversion
|
|
of C Esc sequences e.g \n \t \r \b
|
|
|
|
For example:
|
|
|
|
#command TEXT TO VAR <var> => ;
|
|
#pragma __cstream|%s||<var>:=
|
|
|
|
TEXT TO VAR v
|
|
This is 'example' text with ''""[] embedded and C \n
|
|
sequence
|
|
ENDTEXT
|
|
? v
|
|
|
|
The above example is preprocessed into:
|
|
v:=[This is 'example' text with ''""[] embedded and C \nsequence]
|
|
QOut(v)
|
|
|
|
and at runtime the following is printed:
|
|
|
|
This is 'example' text with ''""[] embedded and C
|
|
sequence
|
|
|
|
#pragma __endtext
|
|
-----------------
|
|
Syntax:
|
|
#pragma __endtext
|
|
|
|
This pragma is used to finish the special processing defined with
|
|
#pragma [__text | __stream | __cstream]
|
|
|
|
The following command is hardcoded in the preprocessor:
|
|
|
|
#xcommand ENDTEXT => #pragma __endtext
|
|
|
|
#pragma RECURSELEVEL
|
|
--------------------
|
|
Syntax:
|
|
#pragma RECURSELEVEL <nNumberOfIterations>
|
|
|
|
This pragma sets the maximum number of preprocess iterations during
|
|
the source code translation. The default value is 1024.
|
|
This is the same as /r= command-line switch
|
|
|
|
For example:
|
|
|
|
#pragma RECURSELEVEL 2048
|