SAL annotations not understood on Windows

Issue #62 new
Neil Hodgson
created an issue

On Windows, the system headers contain annotations in SAL, a source code annotation language which describes function parameters in a richer way than is possible with the basic C language. These annotations can, for example, specify whether it is possible to pass NULL for a pointer parameter and how to pass sizes for array parameters.

cffi could use this information in several ways such as passing the correct size for an array argument instead of relying on the client code to specify this correctly. Exceptions could be raised by cffi when client code uses incorrect parameters such as passing NULL to a non-opt (optional) parameter.

The language is described here: http://msdn.microsoft.com/en-us/library/ms235402(v=vs.80).aspx

Simply allowing and ignoring SAL would also offer a small benefit. Currently the user should remove the annotations when copying system function prototypes into cffi-based source, but every edit made increases the possibility of error.

Comments (2)

  1. Armin Rigo

    I'm keeping this issue on the back of my mind, but at a very low priority. It would be interesting if there was general annotations that we could follow on other platforms as well, but I haven't seen that on other platforms than Windows. We could support some SAL subset on all platforms. In the meantime, please note that I documented a regexp that removes the SAL annotations, to avoid making edits in the cdef():

    http://cffi.readthedocs.io/en/latest/cdef.html#ffi-ffibuilder-cdef-declaring-types-and-functions

  2. Log in to comment