Skip to main content Accessibility help
×
Hostname: page-component-cd9895bd7-jkksz Total loading time: 0 Render date: 2024-12-24T18:14:40.240Z Has data issue: false hasContentIssue false

6 - Interfacing to C: SQLite As an Example

Published online by Cambridge University Press:  05 July 2012

Arjen Markus
Affiliation:
Deltares, Delft, The Netherlands
Get access

Summary

Quite often the public interface of a library that you are interested in is written in a different programming language than the one you use. You will need an interface library that bridges the gap between both languages. This is the case with SQLite, a lightweight database management system [44]. It is written in C and there is a host of libraries to communicate with SQLite in all manner of languages.

For Fortran, there is the fsqlite library that I developed. It was inspired by the work of Al Danial [27], but focused on FORTRAN 77, that was mainly an example of how you could interface to the SQLite library. I wanted a generic solution instead.

The design decisions and the implementation of fsqlite illustrate a more general question: how to combine Fortran and other programming languages? Each time you need to consider:

  1. ■ Low-level aspects of the combination:

  2. - How do the basic types of the two languages relate to each other?

  3. - What are the naming and calling conventions?

  4. ■ High-level aspects relating to the actual library: What is a good “model” for the interface? Should you simply write wrapping routines that merely translate the routine interfaces or should you build a higher-level interface, molding the original interface into something that is a better fit for the library's use?

This chapter will cover both types of issues in the context of interfacing with C (an intermediate layer in C is often a convenient way to communicate with any other language) and of the interface to SQLite.

Type
Chapter
Information
Publisher: Cambridge University Press
Print publication year: 2012

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure [email protected] is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

Available formats
×