RetroBSD

2.11BSD operating system for microcontrollers
It is currently Tue Feb 25, 2020 5:34 pm

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Sat Sep 28, 2013 7:46 pm 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
# cd share
# ls
example man misc re.help smallc
# cd smallc
# ls
Makefile gpio.c primelist.c q8.c test1.c test3.c
adc.c hello.c primesum.c rain.c test2.c webserver.c
# make
scc -o hello hello.c
#extern int printf();
# ^
#****** missing semicolon ******
#extern int printf();
# ^
#****** illegal function or declaration ******
#int main()
# ^
#****** missing semicolon ******
#int main()
# ^
#****** illegal function or declaration ******
#{
#^
#****** illegal function or declaration ******
# printf ("Hello, SmallC World!\n");
# ^
#****** already defined ******
# printf ("Hello, SmallC World!\n");
# ^
#****** illegal argument name ******
# printf ("Hello, SmallC World!\n");
# ^
#****** expected comma ******
# printf ("Hello, SmallC World!\n");
# ^
#****** expected comma ******
# printf ("Hello, SmallC World!\n");
# ^
#****** illegal argument name ******
# printf ("Hello, SmallC World!\n");
# ^
#****** expected comma ******
# printf ("Hello, SmallC World!\n");
# ^
#****** illegal argument name ******
# printf ("Hello, SmallC World!\n");
# ^
#****** expected comma ******
# printf ("Hello, SmallC World!\n");
# ^
#****** illegal argument name ******
# printf ("Hello, SmallC World!\n");
# ^
#****** wrong number args ******
# printf ("Hello, SmallC World!\n");
# ^
#****** function requires compound statement ******
#}
#^
#****** illegal function or declaration ******
Compilation failed: 17 error(s)
*** Exit 1

Stop.

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Sat Sep 28, 2013 10:02 pm 
Committer
User avatar

Joined: Thu Oct 11, 2012 8:45 am
Posts: 1801
Location: Room 217, Floor 8, Arm 8, Wheel S7, Mars Base Alpha 3
Compiles using srcc, but not scc. I don't know what the difference is.

Edit: scc is small c, srcc is smaller c.

scc uses the strange broken Small C format of program, srcc uses a proper C formatted file.

_________________
Why not visit my shop? http://majenko.co.uk/catalog
Universal IDE: http://uecide.org
"I was trying to find out if it was possible to only eat one Jaffa Cake. I had to abandon the experiment because I ran out of Jaffa Cakes".


Top
 Profile  
 
PostPosted: Sun Sep 29, 2013 7:45 am 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
srcc:
Code:
# make
srcc  -o hello  hello.c
srcc  -o primelist  primelist.c
Error in "primelist.c" (4:5)
Error: ParseBlock(): Unexpected token <Ident>
*** Exit 1

Stop.

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Mon Sep 30, 2013 10:04 pm 
Committer
User avatar

Joined: Thu Oct 11, 2012 8:45 am
Posts: 1801
Location: Room 217, Floor 8, Arm 8, Wheel S7, Mars Base Alpha 3
Hello is the only one that has been converted for srcc - the others are all still scc. Take a look at them and you'll soon see the differences.

_________________
Why not visit my shop? http://majenko.co.uk/catalog
Universal IDE: http://uecide.org
"I was trying to find out if it was possible to only eat one Jaffa Cake. I had to abandon the experiment because I ran out of Jaffa Cakes".


Top
 Profile  
 
PostPosted: Wed Oct 02, 2013 11:39 am 
Contributor

Joined: Mon Apr 29, 2013 1:56 am
Posts: 196
Pito wrote:
srcc:
Code:
# make
srcc  -o hello  hello.c
srcc  -o primelist  primelist.c
Error in "primelist.c" (4:5)
Error: ParseBlock(): Unexpected token <Ident>
*** Exit 1

Stop.


SmallerC does not support implicit int in declarations like:
Code:
main()
{
...
}


It must be:
Code:
int main()
{
...
}

The C99 standard (to which I'm leaning) does not support implicit int unlike the earlier standard, C89.

And it does not support the ancient, ungodly K&R parameter declaration syntax a few lines down from there (again, per C99):
Code:
isprime(n)
    int n;
{


It must be:
Code:
int isprime(int n)
{


You'll also have to declare functions before using them (e.g. printf()) as required by the same C99. Any one of these should do:
Code:
extern int printf(char*, ...); // or
int printf(char*, ...); // or
extern int printf(); // or
int printf();


Some of these things are called out explicitly on the Smaller C wiki page: https://github.com/alexfru/SmallerC/wiki/Smaller-C-Wiki. But it wouldn't hurt to improve it a bit with even more explicit things. Imagine that! :lol: Pun intended.


Top
 Profile  
 
PostPosted: Thu Oct 03, 2013 8:39 pm 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
It would be great to decide which compiler shall be used actually with which sources..
The stuff shall work (compile) when put into repo..

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Mon Feb 24, 2014 5:05 am 
Contributor

Joined: Mon Apr 29, 2013 1:56 am
Posts: 196
Pito wrote:
It would be great to decide which compiler shall be used actually with which sources..
The stuff shall work (compile) when put into repo..


I agree, the mess we've created needs cleanup. Looks like Serge is swamped with work and can't do much (if any) of RetroBSD related stuff these days and I've been working on the compiler itself only, which isn't a small thing either.

Speaking of which, I've already added a number of features and improvements in Smaller C, among which are things like:

    signed char, unsigned char (there used to be only a plain char)
    short, long
    struct, union
    ?:
    type casts
    goto

This "feature richness" probably means that Smaller C should become the default compiler running on RetroBSD (or superseding Small C) and that the examples should all be converted to it (and the library headers should be created/updated for Smaller C, wherever lacking).

I've pinged Serge multiple times about these Smaller C updates and I'm still waiting for him to copy the newest code over from github to google code. But you can always grab it from github yourself.

Remember to read the Smaller C wiki page for the latest state and compilation instructions (e.g. how to compile for RetroBSD, there's a note on that there, just look for RetroBSD).


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron




Powered by phpBB® Forum Software © phpBB Group

BSD Daemon used with permission