Author Topic: Tiny "c" info  (Read 5012 times)

jcfuller

  • Sr. Member
  • ****
  • Posts: 412
    • View Profile
Tiny "c" info
« on: August 26, 2020, 04:55:23 AM »
From a post on the FreeBasic forum that might be interest some here?

https://www.freebasic.net/forum/viewtopic.php?f=17&t=28775

James

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 2229
    • View Profile
Re: Tiny "c" info
« Reply #1 on: August 26, 2020, 10:53:32 AM »
Quote
(by D.J.Peters » Aug 26, 2020 2:33 )
I tested the tiny c compiler "tcc" version 0.9.27
One of the new TinyCC features are the compiler option -m32/-m64

To be clear, there is nothing "new" here.

Everything inside those zips are dated 2017 and I suspect the headers and libs are older still. 



Robert

  • Hero Member
  • *****
  • Posts: 1237
    • View Profile
Re: Tiny "c" info
« Reply #2 on: August 26, 2020, 01:21:16 PM »
Quote
(by D.J.Peters » Aug 26, 2020 2:33 )
I tested the tiny c compiler "tcc" version 0.9.27
One of the new TinyCC features are the compiler option -m32/-m64

To be clear, there is nothing "new" here.

Everything inside those zips are dated 2017 and I suspect the headers and libs are older still.

"New", last change, Fri, 21 Aug 2020 13:47:56 -0700 (21 22:47 +0200)

is at Git URL

git://repo.or.cz/tinycc.git


MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 2229
    • View Profile
Re: Tiny "c" info
« Reply #3 on: August 26, 2020, 01:56:26 PM »
Robert,

Yes ... I visited github before I responded to JC's post.

I observed a number of forks (mirrors)

https://github.com/search?o=desc&q=tinycc&s=updated&type=Repositories

Frankly, I don't see the allure with so many better alternatives available.

Yes ... it's fast, small, and free.

Reminds me of an old engineering joke:  Cheap, fast, and correct ... pick two.

Robert

  • Hero Member
  • *****
  • Posts: 1237
    • View Profile
Re: Tiny "c" info
« Reply #4 on: August 26, 2020, 02:26:25 PM »
Robert,

Yes ... I visited github before I responded to JC's post.

I observed a number of forks (mirrors)

https://github.com/search?o=desc&q=tinycc&s=updated&type=Repositories

Frankly, I don't see the allure with so many better alternatives available.

Yes ... it's fast, small, and free.

Reminds me of an old engineering joke:  Cheap, fast, and correct ... pick two.

Hi MrBCX:

If I recall correctly, claims were made in the past that tcc would compile 64 bit inlne assembly code. I never tried it. It would be interesting to see if BCX_DYNACALL worked as a 64 bit tcc compile.

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 2229
    • View Profile
Re: Tiny "c" info
« Reply #5 on: August 26, 2020, 03:04:00 PM »

Hi MrBCX:

If I recall correctly, claims were made in the past that tcc would compile 64 bit inlne assembly code. I never tried it. It would be interesting to see if BCX_DYNACALL worked as a 64 bit tcc compile.

Maybe I'll take up that challenge just to satisfy curiosity.   

The MakeGuidFromString () that I posted yesterday was initially much easier to
implement but limited to 32-bit apps only because of its dependency on Dynacall:

FUNCTION MakeGuidFromString (MyStr$, MyGUID AS LPGUID)
  FUNCTION = UuidFromString (LIB "Rpcrt4.dll", MyStr$, MyGUID)
END FUNCTION


Overcoming that 32-bit limitation is why I decided rewrite it thusly :


'FUNCTION MakeGuidFromString (MyStr$, MyGUID AS LPGUID)
'  '***************************************************
'! typedef int( __stdcall *UIDFS )(PCHAR,LPGUID);
'  '***************************************************
'  DIM hDll AS HMODULE
'  DIM MakeUUID AS UIDFS
'  LOCAL RetCode

'  hDll = LOADLIBRARY("Rpcrt4.dll")
'  IF hDll = NULL THEN
'    PRINT  "Could not load Rpcrt4.dll"
'    FUNCTION = 0
'  END IF

'  $IFDEF UNICODE
'    MakeUUID = GetProcAddress(hDll, "UuidFromStringW")
'  $ELSE
'    MakeUUID = GetProcAddress(hDll, "UuidFromStringA")
'  $ENDIF

'  IF MakeUUID = NULL THEN
'    PRINT  "Could not locate the function: UuidFromString()"
'    FreeLibrary(hDll)
'    FUNCTION = 0
'  END IF

'  RetCode = MakeUUID (MyStr$, MyGUID)
'  FreeLibrary(hDll)
'  FUNCTION = RetCode
'END FUNCTION

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 2229
    • View Profile
Re: Tiny "c" info
« Reply #6 on: August 26, 2020, 03:22:14 PM »
And the answer is: NO

C:\Temp\tcc-win64>tcc -c  test.c -m64

test.c:239: error: bad operand with opcode 'pushl'


SOURCE OF ERROR:

#elif defined( __MINGW32__ ) || defined( __TINYC__)
__asm__("pushl %0" : : "r" (arg));     <<<-------------------------------------

Robert

  • Hero Member
  • *****
  • Posts: 1237
    • View Profile
Re: Tiny "c" info
« Reply #7 on: August 26, 2020, 03:32:47 PM »
And the answer is: NO

C:\Temp\tcc-win64>tcc -c  test.c -m64

test.c:239: error: bad operand with opcode 'pushl'


SOURCE OF ERROR:

#elif defined( __MINGW32__ ) || defined( __TINYC__)
__asm__("pushl %0" : : "r" (arg));     <<<-------------------------------------

Instead of "pushl" try "pushq"

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 2229
    • View Profile
Re: Tiny "c" info
« Reply #8 on: August 26, 2020, 04:10:50 PM »
Sorry ... still no love ...

error: bad operand with opcode 'pushq'

Robert

  • Hero Member
  • *****
  • Posts: 1237
    • View Profile
Re: Tiny "c" info
« Reply #9 on: August 26, 2020, 04:51:41 PM »
Sorry ... still no love ...

error: bad operand with opcode 'pushq'

Thanks for that.

I had tcc setup a few years ago and am trying again but am having trouble with complaints about the Windows headers. I don't know if I have that patience for this anymore. It used to be fun but after a few times it gets old real fast.

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 2229
    • View Profile
Re: Tiny "c" info
« Reply #10 on: August 26, 2020, 05:03:11 PM »
Tcc has a fraction of the headers and libs that one finds in other compiler systems.



psbrsneiman

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Tiny "c" info
« Reply #11 on: March 24, 2021, 08:28:58 PM »
There is a separate download for https://download.savannah.gnu.org/releases/tinycc/winapi-full-for-0.9.27.zip

I had to add it when I liked to add Unicode to my programs.


JohnClaw

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Tiny "c" info
« Reply #12 on: August 31, 2023, 03:13:27 PM »
Does exist some way to use Tiny C with BCX?

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 2229
    • View Profile
Re: Tiny "c" info
« Reply #13 on: August 31, 2023, 06:10:10 PM »
Does exist some way to use Tiny C with BCX?

Hello and welcome to the forum.

I have not messed around with Tcc for 15 years.  What I remember is that TCC was
able to compile many of the sample BCX console apps and a few of simple GUI apps. 

To get started, I suggest writing a simple Test.bas:   PRINT "Hello, World"

Translate Test.bas with BCX like this at command prompt:

BC Test

BCX BASIC to C/C++ Translator (c) 1999-2023 by Kevin Diggins
Version 8.0.4 (08/31/2023) Compiled using MS Visual C++ for 64-bit Windows Systems
[Lines In: 1] [Lines Out: 239] [Statements: 2] [Time: 0.01 Sec's]
BCX translated [Test.Bas] to [Test.C] for a C Compiler

Try to compile with TCC like this:

TCC Test.c  -luser32 -lkernel32 -ladvapi32 -lcomctl32 -lshell32 -lole32 -lgdi32 -lcomdlg32

I know many of those libraries are not needed.  I remember that those were the most commonly
needed when compiling BCX generated code.  It might take some trial and error but you will get
there if you stick with it.

Don't be afraid of error messages or warnings.  They happen and they can teach you what you
need to fix.  If you get stuck, ask questions here.  Someone will try to help you.

  ~MrBcx~


JohnClaw

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Tiny "c" info
« Reply #14 on: August 31, 2023, 06:37:45 PM »
I tried to follow your instructions but got this error:

tcc: error: library 'kernel32.lib' not found
tcc: error: library 'user32.lib' not found
tcc: error: library 'gdi32.lib' not found
tcc: error: library 'comctl32.lib' not found
tcc: error: library 'advapi32.lib' not found
tcc: error: library 'winspool.lib' not found
tcc: error: library 'shell32.lib' not found
tcc: error: library 'ole32.lib' not found
tcc: error: library 'oleaut32.lib' not found
tcc: error: library 'uuid.lib' not found
tcc: error: library 'odbc32.lib' not found
tcc: error: library 'odbccp32.lib' not found
tcc: error: library 'winmm.lib' not found
tcc: error: library 'comdlg32.lib' not found
tcc: error: library 'imagehlp.lib' not found
tcc: error: library 'version.lib' not found