Polyglot

From SourceWiki
Jump to navigation Jump to search

Mixing Languages

Introduction

Languages have their pros and cons.

svn export http://source.ggy.bris.ac.uk/subversion-open/polyglot/trunk ./polyglot

The first example is calling a Fortran routine from C.

Things to get right:

  • use 'nm' or a similar program to investigate the name mangling used by your Fortran compiler, so that you can match the name in your C program.
  • matching the sizes of variables
  • pass by reference, pass by value
  • fortran indexes arrays from 1, by defualt; C from 0.
  • The rows/columns are reversed from Fortran to C.