PDA

View Full Version : Help Compiling Small C Source in Mac OS X


mechgyver
07-06-07, 10:58 AM
Has anyone had any success compiling Pete Gray's Small C compiler source code using terminal and gcc on an Intel Mac running OS X 10.4.10?

For example, I have been trying the following compile command:
gcc -o cc1.o cc1.c
However, I just get a huge list of errors:

cc1.c: In function 'getarg':
cc1.c:17: warning: assignment makes integer from pointer without a cast
cc1.c:21: warning: assignment makes pointer from integer without a cast
cc1.c:23: warning: comparison between pointer and integer
cc1.c:26: warning: assignment makes integer from pointer without a cast
cc1.c: In function 'main':
cc1.c:130: warning: incompatible implicit declaration of built-in function 'calloc'
cc1.c:152: warning: passing argument 1 of 'fclose' makes pointer from integer without a cast
cc1.c: In function 'doinclude':
cc1.c:291: warning: assignment makes integer from pointer without a cast
cc1.c:292: warning: assignment makes integer from pointer without a cast
cc1.c:292: warning: comparison between pointer and integer
cc1.c: In function 'dodefine':
cc1.c:323: warning: incompatible implicit declaration of built-in function 'abort'
cc1.c:323: error: too many arguments to function 'abort'
cc1.c: In function 'dofunction':
cc1.c:360: warning: assignment makes pointer from integer without a cast
cc1.c: In function 'doargs':
cc1.c:422: warning: assignment makes pointer from integer without a cast
cc1.c: In function 'compound':
cc1.c:543: warning: assignment makes pointer from integer without a cast
cc1.c: In function 'addlabel':
cc1.c:696: warning: assignment makes pointer from integer without a cast
cc1.c:703: warning: assignment makes pointer from integer without a cast
cc1.c: In function 'dobreak':
cc1.c:717: warning: assignment makes pointer from integer without a cast
cc1.c: In function 'docont':
cc1.c:729: warning: assignment makes pointer from integer without a cast
cc1.c: In function 'doasm':
cc1.c:745: warning: passing argument 2 of 'fputs' makes pointer from integer without a cast
cc1.c: In function 'ask':
cc1.c:773: warning: assignment makes integer from pointer without a cast
cc1.c:798: warning: incompatible implicit declaration of built-in function 'abort'
cc1.c:798: error: too many arguments to function 'abort'
cc1.c: In function 'openfile':
cc1.c:821: warning: incompatible implicit declaration of built-in function 'strcpy'
cc1.c:833: warning: assignment makes integer from pointer without a cast
cc1.c: In function 'mustopen':
cc1.c:842: warning: assignment makes integer from pointer without a cast
cc1.c:845: warning: incompatible implicit declaration of built-in function 'abort'
cc1.c:845: error: too many arguments to function 'abort'

Any help or advice would be greatly appreciated!

Thanks!

peterfgray
07-09-07, 11:37 AM
Hi. I don't think anyone has attempted to compile Small C on Mac OS X before. However, my understanding is that OS X is actually just a flavor of Linux. That being said, Linux (actually, gcc) has evolved a lot since the original port - looks to me like Small C needs some attention in order to catch up with the evolution.

Ignoring the warnings for now, it looks like the main culprit - 'abort' - is now tagged as a built-in function. If there's a function in the Small C compiler called 'abort', it'll need to be renamed to something like 'do_abort' in order to distinguish it from the built-in function, and calls will need to reference the renamed function.

Regards,
-Pete.

mechgyver
07-17-07, 02:55 PM
Hi Peter,

Thanks for responding so quickly!

As you suggested I renamed the 'abort' function and that got rid of many of the errors. There were still some other errors, but I'll try tackling those when I get a chance and post the results.

Again, thanks for the help!

idknow
10-08-07, 04:57 AM
hi folks.

I've been reading the posts here about Smallc and would like to add a few notes and pointers to help.

1. There is a modest summary page that I helped edit on Wikipedia, search for "smallc"; the page there mentions the various versions of smallc that I've found around the net.

2. smallc is not compliant with any standard describing the language, its syntax nor its semantics.

as far as I know, there are two main branches of the compiler, a version one tree and a version two tree.

version two is significant by its complete rewrite of the code generator in cc4.c, a rewrite of the expression parser in cc3 and alot of reorganisation of the functions across the whole source code.

version one is usually found in one source file, altho due to its age, and the machines to which Smallc has been ported the compiler is usually broken up into alot of smaller files.

In one of the posts on this forum, I noticed a question regarding why an error was generated when "int" or "char" preceeds the name of a function being defined. The reason is that the typing of functions is a feature of the ANSI C standard, of which Smallc is not an adherent.

Smallc (unmodified versions) can only return char, int, or pointer, and no functino typing is allowed.

However, it is a trivial matter for the compiler to be modified to accept (and possibly ignore) the typing.

I hope this hopes.

btw, where's the dsp.zip that I've seen mentioned elsewhere here? :)

stay well.

P. S. in most zipfiles of smallc that I've seen there is documentation regarding the compiler; there's also a macro assembler written in smallc and several books have been printed. and of course, source code galore.

Smallc is a hacking compiler; it's meant to be enhanced - don't just use it as is, change it, fix it, share what you've done.

sreeja
11-07-07, 01:00 AM
How we can compile small c on Mac OXs.

idknow
08-11-10, 10:45 AM
How we can compile small c on Mac OXs.

you need to rename several functions in the source file, ie,

s/abort/die/g;
s/getline/refill/g

then you need to change the getline()/refill() to properly process input to either ignore DOS end of lines or swallow both if( eol == \r or \n) ...

there are other things to do also - ask a question.