[Top][All Lists]

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

Re: [Tinycc-devel] When a DLL isn't a DLL.

From: Mike
Subject: Re: [Tinycc-devel] When a DLL isn't a DLL.
Date: Sat, 10 Aug 2013 01:22:00 -0400
User-agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8

In C, you can specify a calling convention, or the compiler uses its default. I think the default in most C compilers is "cdecl". I'd say, when exporting C code to other languages, you should explicitly specify the calling convention for the exported functions.

When calling from another language, you must specify the calling convention of the C code. If you get this wrong, it's a crash.

Understand this page.

This perl Win32::API call functionality you speak of, probably assumes "winapi" calling convention, which means "stdcall" on windows 32 bit, "fastcall" on windows 64 bit, and "cdecl" on mobile windows. I'd recommend using perl functionality that lets you specify the calling convention.

TCC's outputed DLLs/EXEs are normal. But .o files from TCC are ELF binaries, which is strange and makes things a little incompatible.

On 8/9/2013 2:30 PM, livespi wrote:
Greetings all,
Does anyone here have cross-language knowledge/experience with Perl on
I can build dll's with tcc using the "-shared" flag, and they work fine
when I  call the dll functions FROM a tcc program.

Perl has a package Win32::API which allows you to call dll functions from
within  a Perl script.  It works fine when calling dll's that come from
Microsoft.   However, when I call my dll's built with tcc, Perl crashes.
 From research on the  web, this indicates an incompatible "calling
convention" i.e. stack arrangement  for function calls. I have to re-build
my dll's with mingw-gcc and dlltool  (which comes with StrawberryPerl)
before I can use them with Perl. This doesn't  make sense to me because
tcc can call MS dll's.

Are the dll's produced by tcc not the same as the dll's from Microsoft?  Is
this  a known issue?  If so, why have the -shared flag at all and just use
a .a or  .lib? I thought tcc was compatible with mingw gcc.

If anyone can shed some light on this I would be grateful.

                        *** WinXP using Popcorn email client

Tinycc-devel mailing list

reply via email to

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