Re: tcc - first impression. Was: Baby X is bor nagain

Liste des GroupesRevenir à cl c  
Sujet : Re: tcc - first impression. Was: Baby X is bor nagain
De : already5chosen (at) *nospam* yahoo.com (Michael S)
Groupes : comp.lang.c
Date : 03. Jul 2024, 11:57:00
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240703135700.00002f08@yahoo.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
User-Agent : Claws Mail 4.1.1 (GTK 3.24.34; x86_64-w64-mingw32)
On Tue, 2 Jul 2024 16:27:04 +0300
Michael S <already5chosen@yahoo.com> wrote:

On Tue, 2 Jul 2024 12:22:53 +0100
bart <bc@freeuk.com> wrote:
>
Both make use of msvcrt.dll. I don't consider it a dependency since
it has always been part of Windows. (I first starting using it in
1990s, from my other language, before I knew much about C, as it had
a simpler file API than Windows.)
 
Lots of other applications use it too. Including older gcc binaries
and applications compiled with those.
 
On Windows 11, probably 10 too, msvcrt.dll's printf routines
support %zu, and so does Tcc.
 
 
Not really.
DLL that supports newer feature has different name - VCRUNTIME140.dll
And choice of DLL version is not directly related to the version of
Windows.
 
 
 
 
 

I tried to use new Microsoft library from tcc. It is not hard, but not
quite as simple as repacing the name of DLL.
Here is step-by-step example with dynamic load of DLL (most of the
underscored nonsense that I copied from MS's stdio.h likely
non-necessary):


#include <windows.h>
#include <stdarg.h>
#include <stdio.h>

FILE* __cdecl (*__acrt_iob_func)(unsigned _Ix);
int __cdecl (*__stdio_common_vfprintf)(
  unsigned __int64 _Options,
  FILE*            _Stream,
  char const*      _Format,
  _locale_t        _Locale,
  va_list          _ArgList
);

_Bool init(void)
{
  HINSTANCE libinst=LoadLibrary("ucrtbase");
  if (!libinst) {
    printf("LoadLibrary() Fail. Error %u.\n", GetLastError());
    return 0;
  }
  FARPROC l__acrt_iob_func = GetProcAddress(libinst, "__acrt_iob_func");
  if (!l__acrt_iob_func) {
    printf("GetProcAddress(__acrt_iob_func) Fail. Error %u.\n",
GetLastError()); return 0;
  }
  FARPROC l__stdio_common_vfprintf = GetProcAddress(libinst,
"__stdio_common_vfprintf"); if (!l__stdio_common_vfprintf) {
    printf("GetProcAddress(__stdio_common_vfprintf) Fail. Error %u.\n",
GetLastError()); return 0;
  }
  __acrt_iob_func = l__acrt_iob_func;
  __stdio_common_vfprintf = l__stdio_common_vfprintf;
  return 1;
}

__declspec(noinline) __inline unsigned __int64* __cdecl
__local_stdio_printf_options(void) {
  static unsigned __int64 _OptionsStorage;
  return &_OptionsStorage;
}

__inline int __cdecl _vfprintf_l(
  FILE*       const _Stream,
  char const* const _Format,
  _locale_t   const _Locale,
  va_list           _ArgList)
{
  return __stdio_common_vfprintf((*__local_stdio_printf_options()),
_Stream, _Format, _Locale, _ArgList); }

__inline int ucrt_printf(char const* const format, ...)
{
  va_list argList;
  va_start(argList, format);
  int result = _vfprintf_l(__acrt_iob_func(1), format, 0, argList);
  va_end(args);
  return result;
}

int main(void) {
  if (init())
    ucrt_printf("sizeof void* = %zu\n", sizeof(void*));
  return 0;
}


If tcc is still maintained and assuming that licenses are compatible,
and assuming that a little bit of bloat is acceptable, tcc maintainer
can copy necessary stubs from mingw project.



Date Sujet#  Auteur
27 Jun 24 * Re: Baby X is bor nagain36Tim Rentsch
27 Jun 24 +* Re: Baby X is bor nagain2Keith Thompson
28 Jun 24 i`- Re: Baby X is bor nagain1Tim Rentsch
28 Jun 24 +* Re: Baby X is bor nagain11bart
28 Jun 24 i+- Re: Baby X is bor nagain1Tim Rentsch
28 Jun 24 i+- Re: Baby X is bor nagain1Tim Rentsch
28 Jun 24 i+* Re: Baby X is bor nagain7Kaz Kylheku
28 Jun 24 ii+- Re: Baby X is bor nagain1Michael S
28 Jun 24 ii`* Re: Baby X is bor nagain5bart
28 Jun 24 ii +* Re: Baby X is bor nagain2bart
28 Jun 24 ii i`- Re: Baby X is bor nagain1bart
28 Jun 24 ii `* Re: Baby X is bor nagain2bart
28 Jun 24 ii  `- Re: Baby X is bor nagain1Michael S
28 Jun 24 i`- Re: Baby X is bor nagain1bart
1 Jul 24 `* tcc - first impression. Was: Baby X is bor nagain22Michael S
1 Jul 24  +- Re: tcc - first impression. Was: Baby X is bor nagain1Tim Rentsch
1 Jul 24  +* Re: tcc - first impression. Was: Baby X is bor nagain13Keith Thompson
1 Jul 24  i+- Re: tcc - first impression. Was: Baby X is bor nagain1Keith Thompson
2 Jul 24  i+* Re: tcc - first impression. Was: Baby X is bor nagain9Michael S
2 Jul 24  ii+* Re: tcc - first impression. Was: Baby X is bor nagain6bart
2 Jul 24  iii+* Re: tcc - first impression. Was: Baby X is bor nagain4Michael S
2 Jul 24  iiii+* Re: tcc - first impression. Was: Baby X is bor nagain2bart
2 Jul 24  iiiii`- Re: tcc - first impression. Was: Baby X is bor nagain1Michael S
3 Jul 24  iiii`- Re: tcc - first impression. Was: Baby X is bor nagain1Michael S
2 Jul 24  iii`- Re: tcc - first impression. Was: Baby X is bor nagain1Tim Rentsch
2 Jul 24  ii+- Re: tcc - first impression. Was: Baby X is bor nagain1Tim Rentsch
2 Jul 24  ii`- Re: tcc - first impression. Was: Baby X is bor nagain1James Kuyper
2 Jul 24  i`* Re: tcc - first impression. Was: Baby X is bor nagain2Malcolm McLean
2 Jul 24  i `- Re: tcc - first impression. Was: Baby X is bor nagain1Ben Bacarisse
2 Jul 24  +* Re: tcc - first impression. Was: Baby X is bor nagain6Michael S
2 Jul 24  i+* Re: tcc - first impression. Was: Baby X is bor nagain4Ben Bacarisse
2 Jul 24  ii`* Re: tcc - first impression. Was: Baby X is bor nagain3Michael S
2 Jul 24  ii `* Re: tcc - first impression. Was: Baby X is bor nagain2Ben Bacarisse
2 Jul 24  ii  `- Re: tcc - first impression. Was: Baby X is bor nagain1Michael S
3 Jul 24  i`- Re: tcc - first impression. Was: Baby X is bor nagain1Michael S
3 Jul 24  `- Re: tcc - first impression. Was: Baby X is bor nagain1Michael S

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal