Compiler Integration

Top  Previous  Next

With the SoftVelocity 3GL compilers installed, the Clarion development environment takes all the action necessary to call the correct compiler for each source module in the application. You cannot mix languages in a single source module; however, an application can contain any number of source modules written in any of the 3GLs or Clarion.

The development environment calls the correct compiler for each module at compile time by looking at the source file extensions, as follows:

Source File Extension Compiler Called

.CLW    Clarion

.CPP or .C   C++

.MOD    Modula-2

Source files with any other extensions will generate an ‘Unknown compiler for ...’ error message at compile time.

The Development Environment will also ensure that all modules are linked correctly and that the SoftVelocity SmartLinker is given all the information that it requires.

 

Integrating 3GL Modules into Clarion Projects

 

Using the Application Generator:

1. Create an "Include file" containing the function prototypes for the Clarion compiler.

You MUST prototype your functions if you intend to call them from Clarion code (see Procedure Prototyping in the Language Reference). The include file should contain prototypes for all 3GL functions called from Clarion code. Each 3GL module should have its own include file.

The include file is put in the Generated source without modification by step 3 of this process. The generated Clarion code for your include file appears in the Global Map something like this:

 

MODULE(‘module name’)

INCLUDE(‘YourInc.Inc’)

END

 

The Application Generator generates the MODULE and END statements. Failure to correctly prototype your functions will almost certainly result in a General Protection Fault at run time.

2. Use the Text Editor to write your 3GL code.

Be sure to save the code with a file extension that the compiler can recognize (.C, .CPP, .MOD, or .PAS).

3. Add the module to the application as an External Source Module.

Select Application > Insert Module from the main menu. Then select class External Source from the Select Module Type dialog. Press the ellipsis button, and in the Open File dialog, enter the name of the 3GL module in the Name field and click on the Open button, Back in the Module Properties dialog, enter the name of the include file in the Map Include File field of the Module Properties dialog. Press OK to add to the application tree.

4.

Compile and run the application.

 

In a hand-coded Clarion application:

1.  Create the function prototypes for the Clarion compiler.

You must prototype the functions you intend to call from Clarion code (see Procedure Prototyping in the Language Reference). The global MAP structure should contain the prototypes.

Each 3GL module should have its prototypes in a separate MODULE structure, something like this:

 

MODULE(‘module name’)

MyFunc(*CSTRING),CSTRING,RAW,PASCAL,NAME(‘_MyFunc’)

END

 

You must include a complete MODULE structure in your Clarion MAP for all your 3GL modules. Failure to correctly prototype your functions will almost certainly result in a General Protection Fault at run time.

2.  Use the Text Editor to write your 3GL code, saving the code with a file extension that the compiler can recognize (.C, .CPP, .MOD, or .PAS).

3.  Add the module to the Project as an External Source File.

Select Project > Edit from the main menu. Highlight External Source Files then press the Add File... button. Select the 3GL source mofule from the standard file open dialog that appears.

4.  Compile and run the application.