Author Topic: C Basic Class Library  (Read 65672 times)

Offline Charles Pegge

  • BASIC Developer
  • Posts: 69
Re: C Basic Class Library
« Reply #30 on: November 12, 2013, 03:32:48 AM »
Re: compiling on John's Android:

I have fixed the forward reference to StringInstr by moving ths function up the ladder.

and removed the vo->f-> thing.

http://www.allbasic.info/forum/index.php?topic=283
« Last Edit: November 12, 2013, 04:09:17 AM by Charles Pegge »

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: C Basic Class Library
« Reply #31 on: November 12, 2013, 10:45:37 AM »
Charles,

The latest build works on C9 Red Hat 64 bit. I will test it with CINT and Android. Thanks!

Code: [Select]
scriptbasic@c9basic:~/642383/cbclass $ gcc Test.c -o test1
scriptbasic@c9basic:~/642383/cbclass $ ./test1
LO
HELLO
HELLOHELLOHELLO
9
helloLOhellohello
hellohellohello
42.000000
42.000000
AbcAbcAbcAbcAbcAbcAbc
LOLOLOLOLOLOLO
AbcAbcAbcAbcAbcAbcAbc
<
>
  Hello World!
<HELLO WORLD!>
<<HELLO WORLD!>>
HELLO
HELLOH
abc
   \abc
WORD:       aa
Class Size: 80
Char Width: 1
Word Len:   2
Word Start: 13111506
Word End:   13111508
Text End:   13111512
=
scriptbasic@c9basic:~/642383/cbclass $

I gave cint a try in the busted workspace and we seem to have only one issue left. Until I try this in a good workspace or using the WinXP version CINT, use this info with caution.

Code: [Select]
allbasic@c_basic:~/668428/usr/john/cbclass $ cint -p Test.c
Error: illegal pointer to class object vo 0x0 10  FILE:Test.c LINE:18
Error: illegal type cast (2) FILE:Test.c LINE:18
!!! return from main() function

cint>

Update

I got the All BASIC C9 workspace GCC working again. The problem was a C9 gcc wrapper package that I installed to see if it would solve our RH issues with gcc but caused more problems than it solved.

« Last Edit: November 12, 2013, 11:39:38 AM by John »

Offline Charles Pegge

  • BASIC Developer
  • Posts: 69
Re: C Basic Class Library
« Reply #32 on: November 12, 2013, 11:49:12 AM »
Working in RedHet: excellent!

Strange that CINT refers to the word 'class', since vo is instantiated from a type (after preprocessing). Are we interfering with it's namespace here?

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: C Basic Class Library
« Reply #33 on: November 12, 2013, 11:52:47 AM »
I would need to revisit the CINT limitations doc I posted to see why your code isn't working. At least the auto vars went away in cint.

The only thing I can think of that might be causing the problem is the * (PTR) required space in cint. I will do a DIFF of your current version and my cint friendly version and see if that resolves the problem.
« Last Edit: November 12, 2013, 01:22:03 PM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
C Basic Class Library - Android
« Reply #34 on: November 12, 2013, 01:46:04 PM »


jrs@laptop:~/C_BASIC/cbclass$ adb install cbclass.apk
2232 KB/s (332926 bytes in 0.145s)
   pkg: /data/local/tmp/cbclass.apk
Success
jrs@laptop:~/C_BASIC/cbclass$


Note: Attached is the above you can try on your Android device.
« Last Edit: November 12, 2013, 03:11:33 PM by John »

Offline Charles Pegge

  • BASIC Developer
  • Posts: 69
Re: C Basic Class Library
« Reply #35 on: November 12, 2013, 02:36:28 PM »

So the rules are:

No forward references to a procedure without an explicit declaration

No typedef declarations. The full typedef has to be specified before any code that uses it.



Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: C Basic Class Library
« Reply #36 on: November 12, 2013, 02:38:49 PM »
Does this mean you solved the cint issue?

Offline Charles Pegge

  • BASIC Developer
  • Posts: 69
Re: C Basic Class Library
« Reply #37 on: November 12, 2013, 09:38:21 PM »
I see from the docs that CINT is c++. It looks like a class conflict. :)

Posted a new version that uses the word types instead of class.

http://www.allbasic.info/forum/index.php?topic=283
« Last Edit: November 12, 2013, 10:03:57 PM by Charles Pegge »

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: C Basic Class Library
« Reply #38 on: November 12, 2013, 10:38:07 PM »
CINT is an ANSI/ISO C complaint interpreter. The C++ extensions aren't feature rich. CLING is using CLANG which is a C++ only interpreter. The new 6.0 version of ROOT will be based on CLING.

Results
Code: [Select]
allbasic@c_basic:~/668428/usr/john/cbclass $ cint -p Test.c
Error: illegal pointer to class object vo 0x0 9  FILE:Test.c LINE:18
Error: illegal type cast (2) FILE:Test.c LINE:18
!!! return from main() function

cint>

I noticed in the CINT MAN page that the -K option forces C interpretation.

Quote
-K     C mode

Handles given file as C, regardless of file extension. Otherwise, .c files are handled as C and .cxx, .C and .cpp files are handled as C++.

Code: [Select]
allbasic@c_basic:~/668428/usr/john/cbclass $ cint -K -p Test.c
Error: illegal pointer to class object vo 0x0 9  FILE:Test.c LINE:18
Error: illegal type cast (2) FILE:Test.c LINE:18
!!! return from main() function

cint>
« Last Edit: November 13, 2013, 12:10:31 AM by John »

Offline Charles Pegge

  • BASIC Developer
  • Posts: 69
Re: C Basic Class Library
« Reply #39 on: November 13, 2013, 01:28:50 AM »
Somehow we must get it to swallow this pill.

how about:

dim as StringMethods f=(StringMethods) (0+vo->f);

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: C Basic Class Library
« Reply #40 on: November 13, 2013, 02:23:26 AM »
Quote
dim as StringMethods f=(StringMethods) (0+vo->f);


Code: [Select]
allbasic@c_basic:~/668428/usr/john/cbclass $ cint -p Test.c
Error: Symbol vo is not defined in current scope  FILE:StringClass.c LINE:39
Error: Failed to evaluate vo->f
Error: class,struct,union or type StringMethods not defined  FILE:StringClass.c LINE:39
Error: Invalid type 'StringMethods' in declaration of 'f' FILE:StringClass.c LINE:39
allbasic@c_basic:~/668428/usr/john/cbclass $

I have attached the Windows 32 bit binary version of cint . Just point your PATH to the cint base directory. For whatever reason MinGW didn't seem to work. I use the MS VC10 compiler that comes with the Windows SDK 7.

« Last Edit: November 13, 2013, 02:36:40 AM by John »

Offline Charles Pegge

  • BASIC Developer
  • Posts: 69
Re: C Basic Class Library
« Reply #41 on: November 13, 2013, 02:40:36 AM »
This error message does not make sense. It refers to a blank line (39) in stringclass.c :)
« Last Edit: November 13, 2013, 02:42:37 AM by Charles Pegge »

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: C Basic Class Library
« Reply #42 on: November 13, 2013, 02:53:21 AM »
Looks the same to me running on Windows XP using MS VC10 console.

The first run is virgin ZIP and the second is the last change you suggested.

Code: [Select]
F:\cbclass>cint -p Test.c
Test.c
Error: illegal pointer to class object vo 0x0 10  Test.c(18)
Error: illegal type cast (2) Test.c(18)
!!! return from main() function

cint> q
  Bye... (try 'qqq' if still running)

F:\cbclass>cint -p Test.c
Test.c
Error: Symbol vo is not defined in current scope  f:\cbclass\stringclass.c(40)
Error: Failed to evaluate vo->f
Error: class,struct,union or type StringMethods not defined  f:\cbclass\stringclass.c(40)
Warning: Automatic variable StringMethods f is allocated f:\cbclass\stringclass.c(40)

F:\cbclass>

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: C Basic Class Library
« Reply #43 on: November 13, 2013, 03:33:21 AM »
Before anyone asks why are we trying to shotgun debug a debugger, maybe you could download the Windows version I attached and set your PATH to where you unziped it and run it in a VC10 console. I have been showing it run like it was a SB script. Start cint, load the program, set what break points you need and step through the code viewing variables along the way. If we are unwilling to use cint to debug C BASIC code, trying to package it as a tool with C BASIC seems like a waste of our time.

It's late and I'm tired. Good-night.

« Last Edit: November 13, 2013, 03:38:57 AM by John »

Offline Charles Pegge

  • BASIC Developer
  • Posts: 69
Re: C Basic Class Library
« Reply #44 on: November 13, 2013, 03:42:13 AM »
Thanks John, I'll play with VC10 first and deal with any issues there. CINT compatibility further down the list. Sleep well.