[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Function pointers declared in a particular way result

From: Jonathan Newman
Subject: Re: [Tinycc-devel] Function pointers declared in a particular way result in a miscompilation
Date: Tue, 1 Jan 2019 07:37:52 +0000

Hi Christian,
I should have mentioned- my unmodified sqlite build was with these headers (linked somewhere on the official site): http://download.savannah.gnu.org/releases/tinycc/winapi-full-for-0.9.27.zip

I'm also unsure why these are distributed separately/what the rights situation is. It would definitely be nice to clear that up and bundle them with the next release if possible.

- Jonathan

On Tue, 1 Jan 2019, 07:29 Christian Jullien <address@hidden wrote:

Thanks Michael and Jonathan.

Unless I’m missing something in flag or config, sqlite does not compile ROOTB.

I add to  include this dirty patch in sqlite3.c


int MultiByteToWideChar(void);

int WideCharToMultiByte(void);

#define CP_ACP 0

#define CP_UTF8 65001

#define CP_OEMCP 1


In fact, missing declarations are in standard winnls.h Windows header which does not exists in tcc distrib and is explicitly removed (by Grischka?) from windows.h


Line 70: //gr #include <winnls.h>


Which winnls.h have we the rights to include in standard tcc distrib?

We could take the one from MinGW but includes many others includes not present in tcc (should we take them all in tcc standard distrib?).

The ones from PellsC/Watcom/lcc are lighter but I’ve no ideas if we have the rights to do so.


A quick and dirty solution would be to include winnsl.h with only definitions required to compile sqlite and let other people complete this first version with other declaration.





From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=address@hidden] On Behalf Of Jonathan Newman
Sent: mardi 1 janvier 2019 00:25
To: address@hidden
Subject: Re: [Tinycc-devel] Function pointers declared in a particular way result in a miscompilation


Many thanks Michael! I can confirm SQLite now compiles correctly on win32.



On Mon, 31 Dec 2018 at 21:06, Michael Matz <address@hidden> wrote:


On Sat, 29 Dec 2018, Jonathan Newman wrote:

> Hi,This seems to be the issue causing SQLite compilation to fail (or at
> least part of it/related to it).
> When a function pointer is declared in a particular way, it seems that
> __stdcall (and presumably other attributes?) are ignored. As a result, TCC
> thinks the function is caller-cleanup when it is not, and the stack gets
> "cleaned" twice.
> See the full test case attached. As a quick summary,
> This works:
> ((int __stdcall (*)(int, int, int))some_stdcall_func) (2, 0, 0);
> And so does this:
> ((int(*__stdcall)(int, int, int))some_stdcall_func) (3, 0, 0);
> But this fails:
> ((int(__stdcall*)(int, int, int))some_stdcall_func) (4, 0, 0);

Aha, thanks for the investigation and testcase, that really helps.  This
particular problem is now fixed on trunk.  Lacking win32 I can't
check if it completely fixes SQLite, but at least your testcase works when
cross compiled and run under wine.


Tinycc-devel mailing list

Tinycc-devel mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]