C10: Adding StringTheory to a Hand Coded project

Hi Don,

First off, you can think of these settings (project defines) as a sort of constant. By convention The *LinkMode and *DLLMode are (nearly?) always used by the MODULE and LINK attributes of a class. Other defines are commonly used for conditional OMITs and COMPILEs.

More advanced detail: The advantage to setting these defines at the project level vs. as an equate, is that they scope to all files in the project whereas (even a global) an equate might not - this is the case, when you have MEMBER() statement, with nothing between the parenthesis. Such code can be used by many projects, vs. being tied to a particular one. StringTheory.clw is an example of such code.

There are a few ways to add the project defines to your project.

  1. In the solution explorer (the image you posted above),
    right click on the ‘Fixer’ row and select Properties
    then go to the Compiling Tab
    then add the following to the ‘Conditional Compilation Symbols’ entry
    StringTheoryLinkMode=>1;StringTheoryDLLMode=>0
    NOTE: you can click the ‘…’ button
    to show the ; delimited list as a browse, with add / edit / remove buttons

  2. In the solution explorer window, right click on the ‘Projects to include’ line
    and select “add project to include” create a filename with a .PR or .PRJ extension
    in the file add the following lines
    #pragma define(StringTheoryLinkMode=>1)
    #pragma define(StringTheoryDLLMode=>0)

  3. In source (at the appropriate spot) write
    pragma(‘define(StringTheoryLinkMode=>1)’)
    pragma(‘define(StringTheoryDLLMode=>0)’)

    that said, I don’t think there really is an appropriate spot in this case

Also note you can replace
the =>1 with =>on and
the =>0 with =>off
in all of the ways mentioned above,
both notations are identical,
just pick the one that you prefer.

Personally, I tend to use choice #2, mainly because I find it more readable than choice #1.
The Choice #3 technique I reserve for some special pragmas (like profile, and init_priority) where the setting only applies to certain modules. Note: In the solution explorer, you can right click on a module (ex: yada.clw) and select properties, from there you you an fill in DEFINES. These will be module level defines the like the ones I use Choice #3 to accomplish. Here I like Choice #3, as it’s clearer to me that the setting is present.

The same techniques apply to APPs, however to solve certain problems, folks sometimes recommend deleting the .CWPROJ and letting the APP rebuild it. In which case the choice #1 settings are lost.
I recommend putting any pragma’s that will not be automatically recreated by the APP into a .PR or .PRJ file (choice #2 above).

NOTE: *LinkMode and *DLLMode should always have different values.
use LinkMode=>0; DLLMode=>1 when using code exported from another DLL
use LinkMode=>1; DLLMode=>0 all other times

2 Likes