Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use const pointers for arguments of type [in] headers #168

Closed
dhermes opened this issue Jan 10, 2020 · 1 comment · Fixed by #169
Closed

Use const pointers for arguments of type [in] headers #168

dhermes opened this issue Jan 10, 2020 · 1 comment · Fixed by #169

Comments

@dhermes
Copy link
Owner

dhermes commented Jan 10, 2020

See lapack.h for an example already in use, for example

#define LAPACK_dgetrf LAPACK_GLOBAL(dgetrf,DGETRF)
void LAPACK_dgetrf(
    lapack_int const* m, lapack_int const* n,
    double* A, lapack_int const* lda, lapack_int* ipiv,
    lapack_int* info );

has marked m, n and lda constant which matches the [in] arguments from the docs

Screen Shot 2020-01-10 at 10 07 04 AM

I went with the macro-less

extern void dgetrf_(const int* M, const int* N, double* A, const int* LDA,
    int* IPIV, int* INFO);

in a blog post about LAPACK.

@dhermes dhermes self-assigned this Jan 10, 2020
@dhermes dhermes changed the title Use const pointers for arguments of type In in headers Use const pointers for arguments of type [in] headers Jan 10, 2020
@dhermes
Copy link
Owner Author

dhermes commented Jan 10, 2020

As some other prior art, the Intel MKL docs on their LAPACK interface says

The arguments of the C interfaces for the Intel MKL LAPACK functions comply with the following rules:

  • Scalar input arguments are passed by value.
  • Array arguments are passed by reference.
  • Array input arguments are declared with the const modifier.

...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant