Difference between revisions of "Polyglot"
Jump to navigation
Jump to search
Line 17: | Line 17: | ||
* pass by reference, pass by value | * pass by reference, pass by value | ||
* fortran indexes arrays from 1, by defualt; C from 0. | * fortran indexes arrays from 1, by defualt; C from 0. | ||
− | * The rows/columns are reversed | + | * The rows/columns are reversed for 2-dimensional arrays in Fortran to C. Arrays in C are 'row-major' and arrays in Fortran are 'column major'. |
Revision as of 16:57, 26 May 2008
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 for 2-dimensional arrays in Fortran to C. Arrays in C are 'row-major' and arrays in Fortran are 'column major'.