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

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: C Basic Class Library
« Reply #60 on: November 14, 2013, 11:03:13 AM »
Quote
There isn't an automatic garbage collector. (Yet)

I have held that role in my family for years.  ::)

Make money programming in Freebasic

Maybe someone should tell them about JADE.
« Last Edit: November 14, 2013, 01:03:50 PM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: C Basic Class Library
« Reply #61 on: November 15, 2013, 10:54:40 AM »
Charles,

I haven't heard you mention that your tried your C BASIC class library with Windows 64 bit yet. I was doing my once a month updates of Windows 7 64 bit and while there I thought I would give it a try. I used MinGW-TDM64 and it seems to works fine and no additional compiler switches needed.


Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: C Basic Class Library
« Reply #62 on: November 15, 2013, 11:31:55 AM »
AIR,

Is C development on OSX something nobody does? Based on my observations and your previous comments about IUP on that platform, would the C BASIC project be wasting your time testing there?

Offline Charles Pegge

  • BASIC Developer
  • Posts: 69
Re: C Basic Class Library
« Reply #63 on: November 15, 2013, 02:18:39 PM »
I tested on windows gcc 32bit and 64 bit. We are unlikely to see further 64 bit issues, though some caution is needed when storing data to file with unpacked structures. These potentially differ, causing file incompatibility.

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: C Basic Class Library
« Reply #64 on: November 15, 2013, 02:52:26 PM »
Thanks for the update Charles and I will assume you are covering the Windows 32/64 bit front with both gcc & VC####. I'll make sure things run on Linux 32/64 bit and Android. I don't own or have access to any Apple products.

My next effort is to create a C to C BASIC translator. Doing this by hand is getting old.  :-\
« Last Edit: November 15, 2013, 03:41:57 PM by John »

Offline AIR

  • BASIC Developer
  • Posts: 932
  • Coder
Re: C Basic Class Library
« Reply #65 on: November 15, 2013, 07:48:10 PM »
AIR,

Is C development on OSX something nobody does? Based on my observations and your previous comments about IUP on that platform, would the C BASIC project be wasting your time testing there?

C is used all the time, you can intermix C and Objective C with no problems.

IUP's GTK Dependency pretty much kills it's use on OSX.

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: C Basic Class Library
« Reply #66 on: November 15, 2013, 08:09:13 PM »
Thanks for the good news!

Were you able to get Charles's current C BASIC class library to compile and run on OSX?

Did the Cling binary version for OSX 10.x work on your box?


Offline AIR

  • BASIC Developer
  • Posts: 932
  • Coder
Re: C Basic Class Library
« Reply #67 on: November 17, 2013, 12:03:54 PM »
It compiles and runs, with a bunch of warnings (turn on -Wall to see so you/he can fix them).

Quote
In file included from Test.c:2:
In file included from ./BasicClassLibrary.h:10:
./StringClass.c:543:5: warning: expression result unused [-Wunused-value]
    e;                 // boundary of string segment
    ^
./StringClass.c:544:5: warning: expression result unused [-Wunused-value]
    le;                // length of string segment
    ^~
./StringClass.c:545:5: warning: expression result unused [-Wunused-value]
    d;                 // stride for next string segment
    ^
In file included from Test.c:2:
In file included from ./BasicClassLibrary.h:11:
./LexiClass.c:50:31: warning: format specifies type 'int' but the argument has type 'char *' [-Wformat]
    printf("Word Start: %i\n",w->bp);
                        ~~    ^~~~~
                        %s
./LexiClass.c:51:31: warning: format specifies type 'int' but the argument has type 'char *' [-Wformat]
    printf("Word End:   %i\n",w->ep);
                        ~~    ^~~~~
                        %s
./LexiClass.c:52:31: warning: format specifies type 'int' but the argument has type 'char *' [-Wformat]
    printf("Text End:   %i\n",w->et);
                        ~~    ^~~~~
                        %s
./LexiClass.c:100:7: warning: comparison of constant 255 with expression of type 'char' is always true
      [-Wtautological-constant-out-of-range-compare]
      IfRange(33,a,255) {w->xx |= IsWord; break;}
      ^          ~ ~~~
./LexiClass.c:91:40: note: expanded from macro 'IfRange'
  #define IfRange(A,B,C) if ((A<=B)&&(B<=C))
                                       ^
./LexiClass.c:115:7: warning: comparison of constant 255 with expression of type 'char' is always true
      [-Wtautological-constant-out-of-range-compare]
      IfRange(33,a,255)    {w->xx |= IsWord;    break;}
      ^          ~ ~~~
./LexiClass.c:91:40: note: expanded from macro 'IfRange'
  #define IfRange(A,B,C) if ((A<=B)&&(B<=C))
                                       ^
Test.c:5:12: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  function TestStrings()
           ^~~~~~~~~~~
Test.c:80:3: warning: control reaches end of non-void function [-Wreturn-type]
  end
  ^
./BasicDefine.h:12:17: note: expanded from macro 'end'
  #define end   }
                ^
10 warnings generated.

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: C Basic Class Library
« Reply #68 on: November 17, 2013, 12:16:06 PM »
Charles and I don't have a Mac to test on. Were aren't seeing these issues on Windows, Linux or Android. You are the Mac expert and we are counting on you to support that platform. It would be great if you could help Charles along with making his code more OSX compatible.
« Last Edit: November 17, 2013, 12:53:42 PM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: C Basic Class Library
« Reply #69 on: November 17, 2013, 01:25:56 PM »
I take that back. Here is the warnings gcc returns with -Wall on Ubuntu 64 bit.

C BASIC class Libraries
Code: [Select]
jrs@laptop:~/C_BASIC/cbclass$ gcc -Wall Test.c -o test4errors
In file included from BasicClassLibrary.h:10:0,
                 from Test.c:2:
StringClass.c: In function ‘StringMerge’:
StringClass.c:469:9: warning: unused variable ‘wn’ [-Wunused-variable]
     int wn,en,ne,i,tot,wid,kl;
         ^
StringClass.c: In function ‘StringSplit’:
StringClass.c:543:5: warning: statement with no effect [-Wunused-value]
     e;                 // boundary of string segment
     ^
StringClass.c:544:5: warning: statement with no effect [-Wunused-value]
     le;                // length of string segment
     ^
StringClass.c:545:5: warning: statement with no effect [-Wunused-value]
     d;                 // stride for next string segment
     ^
In file included from BasicClassLibrary.h:11:0,
                 from Test.c:2:
LexiClass.c: In function ‘WordInfo’:
LexiClass.c:50:5: warning: format ‘%i’ expects argument of type ‘int’, but argument 2 has type ‘char *’ [-Wformat=]
     printf("Word Start: %i\n",w->bp);
     ^
LexiClass.c:51:5: warning: format ‘%i’ expects argument of type ‘int’, but argument 2 has type ‘char *’ [-Wformat=]
     printf("Word End:   %i\n",w->ep);
     ^
LexiClass.c:52:5: warning: format ‘%i’ expects argument of type ‘int’, but argument 2 has type ‘char *’ [-Wformat=]
     printf("Text End:   %i\n",w->et);
     ^
Test.c: At top level:
Test.c:5:12: warning: return type defaults to ‘int’ [-Wreturn-type]
   function TestStrings()
            ^
Test.c: In function ‘TestStrings’:
Test.c:80:3: warning: control reaches end of non-void function [-Wreturn-type]
   end
   ^
Test.c: In function ‘main’:
Test.c:86:3: warning: control reaches end of non-void function [-Wreturn-type]
   end
   ^
jrs@laptop:~/C_BASIC/cbclass$

C BASIC w/keyword list only
Code: [Select]
jrs@laptop:~/C_BASIC/cintbasic$ gcc -Wall cb.c -o cbtest4errors
jrs@laptop:~/C_BASIC/cintbasic$ ./cbtest4errors
1
2
3
4
5
x is now 6
My guess is 6
6
Double it up
jrs@laptop:~/C_BASIC/cintbasic$

SDL sprite - Ubuntu 64
Code: [Select]
jrs@laptop:~/C_BASIC/xlate$ gcc -Wall -g -O2 testsprite.c -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -DHAVE_OPENGL -L/usr/lib/x86_64-linux-gnu -lSDL -o testsprite
jrs@laptop:~/C_BASIC/xlate$
« Last Edit: November 17, 2013, 01:41:18 PM by John »

Offline AIR

  • BASIC Developer
  • Posts: 932
  • Coder
Re: C Basic Class Library
« Reply #70 on: November 17, 2013, 03:34:04 PM »
Charles and I don't have a Mac to test on. Were aren't seeing these issues on Windows, Linux or Android. You are the Mac expert and we are counting on you to support that platform. It would be great if you could help Charles along with making his code more OSX compatible.

It's not an OS issue, it's a CODING issue.  If you eliminate the warnings (or errors, if they occur) then you should be able to build successfully on any platform that the GNU Compiler Collection supports, with the only caveat being that you need to be aware that not all OS's support all header files (handled by judiciously using IFDEF's).

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: C Basic Class Library
« Reply #71 on: November 17, 2013, 03:59:41 PM »
I'm leaving / incorporating the #include files as part of the main program. I understand there a standard set of includes that go along with most C/C++ programs. I plan on only having a cbasic.h that covers #define(s) and BASIC runtime functions. (including a subset of Charles's class files) I want to get a solid traditional C BASIC working before taking on OOP.


Offline AIR

  • BASIC Developer
  • Posts: 932
  • Coder
Re: C Basic Class Library
« Reply #72 on: November 17, 2013, 06:04:39 PM »
It's not about OOP, though.

If you're ever porting a C/C++ program from one platform to another, there are certain core headers that are not available on certain platforms.  So you have to account for that.  Certain headers on Linux, for example, that don't exist in MinGW for Windows.  Or Functions that are valid in Windows that don't exist elsewhere (not talking about WinApi, but generic C functions that Microsoft provides-like itoa() ).

Stuff like that is what someone hoping to provide a cross-platform solution has to be aware of.  And account for.

This hasn't come up in your implementation yet.  But it's possible that it will down the line, so I'm just making you aware...

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: C Basic Class Library
« Reply #73 on: November 17, 2013, 11:58:44 PM »
Based on our discussions off line, OSX doesn't support a cross platform GUI toolkit worth using. Apple once again has defined their own standards and not willing to share their API on non-Apple products. Just like not being able to run OSX on non-Apple hardware. (legally) They have become an island and worse than Microsoft in this area. This is why I don't own any Apple products or develop exclusively for the platform.

I'm going to take your advice and not spend any effort on Apple until IUP has a native Cocoa GUI version. (the IUP folks don't seem too motivated and I can see why)

Quote from: IUP site
Why Not Mac? The first Mac driver was developed for MacOS 9 and had several memory limitations so it was abandoned. With Mac OS X we have the opportunity to do something better. Today IUP runs on Mac OS X using X11 with Motif or GTK. We plan for the future to build a native driver, but it is not a Tecgraf priority.

@AIR - I noticed that your Tiny Times JADE Qt4 example was done on the Mac. Is Qt for the Mac a viable cross platform solution?
« Last Edit: November 18, 2013, 12:55:10 AM by John »

Offline Charles Pegge

  • BASIC Developer
  • Posts: 69
Re: C Basic Class Library
« Reply #74 on: November 18, 2013, 12:56:03 AM »
Thanks Armando and John, I have fixed those warnings.

http://www.allbasic.info/forum/index.php?topic=283

We might be able to engage with OSX at the Opengl Level. I've invested some time in exploring OpenGL-GUI possibilities. All the controls have to be created from scratch, of course, which is either heaven or hell, depending on your coding and design interests :)