Use C functions with Watcom Fortran

  • Context: Fortran 
  • Thread starter Thread starter eddyq
  • Start date Start date
  • Tags Tags
    Fortran Functions
Click For Summary
SUMMARY

Using C functions in Watcom Fortran is achievable by understanding key concepts such as calling conventions, structural definitions, and argument structures. Essential tools include LoadLibrary for loading DLLs and GetProcAddress for retrieving function pointers. The Watcom Fortran programming guide provides comprehensive coverage of calling conventions and necessary conversions between C and Fortran data structures. Properly managing these elements ensures seamless integration of C functions within Watcom Fortran applications.

PREREQUISITES
  • Understanding of calling conventions in programming
  • Familiarity with DLLs and dynamic linking
  • Knowledge of data structure representation in C and Fortran
  • Experience with the Watcom Fortran compiler
NEXT STEPS
  • Study the Watcom Fortran programming guide for detailed information on calling conventions
  • Learn how to use LoadLibrary and GetProcAddress in Windows API
  • Research data structure conversion techniques between C and Fortran
  • Explore examples of integrating C functions into Fortran applications
USEFUL FOR

This discussion is beneficial for Fortran developers, C programmers looking to integrate their functions into Fortran, and software engineers working with legacy systems that require cross-language functionality.

eddyq
Messages
8
Reaction score
0
Is there a way to use C functions from Watcom Fortran?
 
Technology news on Phys.org
Take a look at this:

ftp://openwatcom.mirrors.pair.com/archive/11.0c/docs/f77progguide.pdf

The key things just for future notice about using external DLL's written in any language are as follows:

1) Calling convention (for function)
2) Structural definition and memory representation
3) Argument structure (representation of pointers, and machine words like chars, ints, doubles, floats, longs, etc)

The windows standard way of dealing with DLL's is with LoadLibrary for loading the DLL and GetProcAddress to get the function pointer of the DLL.

I had a quick look at the book and it seems to cover the various calling conventions pretty well, but make sure you know how to convert between structures if say a matrix in C is not the same as a matrix in FORTRAN.
 

Similar threads

Replies
64
Views
10K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 25 ·
Replies
25
Views
4K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 3 ·
Replies
3
Views
823
Replies
6
Views
10K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 20 ·
Replies
20
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K