# SQLite Forum

Explicitly specifying the function calling convention in the public functions

# Explicitly specifying the function calling convention in the public functions

### (1) By std_haxxer on 2020-04-08 05:41:44 [link] [source]

Would it be possible to allow explicit specification of the function calling convention in the header file?

The precompiled binaries available on the website seem to have `cdecl` functions. The function definitions in the public header file do not specify a function calling convention. This means linking to this dll requires using `cdecl` as the default calling convention. At the company I work at, we use `stdcall` as the default calling convention, which means it's not possible to link against the precompiled dll easily.

So basically something that looks like this:

``````#ifndef CALLING_CONVENTION
#define CALLING_CONVENTION __cdecl
#endif

...
void CALLING_CONVENTION sqlite3_free(void*);
...
``````

### (2) By Gunter Hick (gunter_hick) on 2020-04-08 06:23:34 in reply to 1 [source]

```Did you see the following snippet from sqlite3.h? Does this not provide for easily building a dll with your own preferred calling convention?

/*
** Provide the ability to override linkage features of the interface.
*/
#ifndef SQLITE_EXTERN
# define SQLITE_EXTERN extern
#endif
#ifndef SQLITE_API
# define SQLITE_API
#endif
#ifndef SQLITE_CDECL
# define SQLITE_CDECL
#endif
#ifndef SQLITE_APICALL
# define SQLITE_APICALL
#endif
#ifndef SQLITE_STDCALL
# define SQLITE_STDCALL SQLITE_APICALL
#endif
#ifndef SQLITE_CALLBACK
# define SQLITE_CALLBACK
#endif
#ifndef SQLITE_SYSAPI
# define SQLITE_SYSAPI
#endif
```

### (5) By std_haxxer on 2020-04-08 22:39:05 in reply to 2 [link] [source]

```I saw those comments before posting this question, but turns out these properties are never actually used in the public header.

It's possible to make my own DLL using a different calling convention but I was trying to use the precompiled DLL downloaded from the website. Someone mentioned that Windows comes with a SQLite DLL in the system32 folder which uses stdcall so that'll work for me, even though the version might be a bit old.
```

### (3) By Richard Hipp (drh) on 2020-04-08 14:55:57 in reply to 1 [link] [source]

You can compile a STDCALL version of the SQLite library as follows:

``````   nmake /f Makefile.msc USE_STDCALL=1 sqlite3.dll
``````

Or, you could just link against `C:\Windows\System32\winsqlite3.dll` which is already compiled to use STDCALL instead of CDECL.

### (4) By std_haxxer on 2020-04-08 22:35:10 in reply to 3 [link] [source]

Thanks! Using the one in system32 will work for my use case.