Amiga.org
Operating System Specific Discussions => Amiga OS => Amiga OS -- Development => Topic started by: cycloid on November 18, 2003, 12:24:22 AM
-
is that right?
it's c code (adoom)
it says "parse error before /" on line 1 of every file.
yes i know // is c++ but it's also c99
gcc 270 is 8 years old or something so is pre 99?
bloody hell all i want to do is compile something and i have to say that gnu lacks so much in terms of FAQs and actual usefull online docs that dont require a lifetime of not having a girlfriend and instead shagging a unix box until you only see the world around you in terms of matrix code.
if you montior these forums you'll know i have a stab at using gcc every so often and i can compile hello world ok on:
1. an amiga
2. a UAE amiga on my PC
3. on my PC
but i'd love to be able to cross compile. and i'm halfway through being able to do that except for the aforementioned rocket science. bloody hell
edit: i have no trouble typing raw c / c++ into microsoft's visual studio and hitting the "build" button by the way. cept i cant use that to make amiga stuff!
-
Why not try to compile your C in C++ mode? A good C program is usually a C++ program too. C that doesn't compile in C++ mode often makes use of dodgy stuff like implicit casting from void* and so on.
I usually tend to compile C stuff in C++ mode as I prefer C++'s stricter enforcemnt of the language rules anyway.
If you want to do C99 stuff, vbcc also supports a few of the C99 extensions.
-
well i went back and started over, i still get the same issues using gcc but now when i use g++ it just says
make: *** [obj/doomdefs.o] Error 1
after, apparently, succesfully compiling doomdef.c ... bah!
makefile:
edit 3: makefile chopped
edit: oh bloody hell! i asserted that i do indeed have gcc270 by unLHAing the arcs into my gnu dir and suddenly it cant find any of my amiga includes! i forgot how to configure that
edit 2: ok so i found a 295 build somewhere and nearly set it up ok except it says there's no include path or something for it to find the includes... i just copied them all into gnu/include and it STILL cant find them argh! now i cant even compile my "test" code which is a standard amigaos prog that simply opens a wb window with text in that you can close... .... nooooo! it used to work as it was the first thing i got going the first time i got gnu going.... noooo!
someone come to my house, slap me round the face and proceed to say. YOU'RE SUPPOSED TO CONFIGURE GCC LIKE THIS!
-
I hear ya buddy. Whilst I rate it as a compiler, I utterly *despise* gcc as a piece of software viewed from a user perspective.
I am not stupid and would regard myself a competent C/C++ programmer. Even my asm isn't too dreadful. So why is it I have *never* got it set up correctly without at least 5 attempts!
To anybody working with / maintaining the amiga gcc port(s): For the love of God, please create a proper installer!
-
ditto, dammit
-
well i found a backup of a working gcc setup. good job that. now i can compile my test window program again. it's a good test one as it invokes a few amiga libs so for it to woork my headers etc have to be set up the same.
i've experimented with simply inserting the gcc bin from 295 and 330 into my setup but it simply wont have it. and anyway, how come every gcc distro has a totally different directory structure with bins and libs in a million subfolders. yeah i know all about targetting and processors but FFS cant it jsut all go in /bin /lib and /include and have that as that!?
-
For Amiga m68k use the GeekGadgets.
Works quite niceley.
VBCC has a switch for // comments.
In gcc I can't find any at the moment.
-
cpp has a -lang-C++ switch which alledgedly allows // comments to be used by gcc but i havent managed to get gcc to pass the argument on to cpp, either that or it's ignoring it.
as for geekgadgets the /current folder has about 1 million tgz files in it and the \alpha\gcc dir has the aforementioned 295 and 330 in, both of which i cant get to work, at all. i probably need some other files to go with them or something.
like was said before. isnt there just a ####ing installer or would that be too easy?
edit: the gg site has an install doc page which lists the packages to get. so i've set my ftp prog off getting, well, everything. i'm in a mind to zip up my "working" 270 for other people to use.
-
cycloid wrote:
like was said before. isnt there just a ####ing installer or would that be too easy?
Dont be silly. l337 haxx0rs don't need no stinking installers ;-)
-
Don't try that bollocks with me, sir. I have a zero tolerence rating for such terminology. Users of non-words like 'l337' and 'w00t' should all be lined up against a wall and shot...
..yes, I am kidding :-)
-
bugger, i downloaded an entire snapshot (990529/bin) from geekgadgets and it doesnt even contain a gcc archive... eh!?!? oh and all the arcs have different version numbers.
someone please help
-
it works! someone on a newsgroup pointed me at the mammoth 80mb golded install download, which i duly dowloaded and installed, then cropped out the gcc 295 and 330 distros. all 99% preconfigured by the installer. hurrah!
unfortunatley i still have the exact same problem i had before: __asm does not work. some minor google scouring seems to suggest that gcc has traditionally bad asm support. but i obviously need asm to be able to link into various os libraries, for example.
so: anyone know how to __asm a function in gcc?
-
Hey dude, is that the golded demo on their site or another one?
-
http://golded.dietmar-eilert.de/golded/files.htm
-
Hmm, thats the one I already got. IIRC the installer skipped gcc saying it wasnt included for size reasons...Better have a closer look at it :lol:
-edit-
Just did - the one I had was 14Mb compressed so not the same at all :-)
-
i'm getting closer. by examining other peoples source i can now properly declare/prototype functions that would, otherwise, use __asm. here it is
#ifdef __SASC
# define SAVEDS __saveds
# define ASM __asm
# define REG(x,y) register __##x y
#elif defined(__GNUC__)
# define SAVEDS __saveds
# define ASM
# define REG(x,y) y __asm(#x)
#elif defined(_DCC)
# define SAVEDS __geta4
# define ASM
# define REG(x,y) __##x y
#elif defined(__STORM__)
# define SAVEDS __saveds
# define ASM
# define REG(x,y) register __##x y
#elif defined(__VBCC__)
# define SAVEDS __saveds
# define ASM
# define REG(x,y) __reg(#x) y
#else
# error add #defines for your compiler...
#endif
if anyone understands, that is, i found it in the blitzquake source: amigacompiler.h, heh.
then you can proto your function thus:
static void ASM thefunction( REG(a1,UBYTE *), REG(a2,UBYTE *), REG(a6,struct Library *));
NEXT PROBLEM:
compiling assembler ("whatever.s") files in gcc (as) ... i get an error for EVERY line of assembler along the lines of:
unknown operator -- statement: ASM STATEMENT
or
parse error -- ASM STATEMENT
and
rest of line ignored, first ignored character is '@'
anyone?
-
If you have a pure assembler file, you need to use an assembler to compile separate object code to be linked later on. The gcc compiler is expecting C syntax, which is why the asm() stuff is needed in the C program.
Maybe gcc has an assembler option that will do the trick. I don't know and can't check because I ain't got it. Someone else should help with that.
-
i knew somebody would say that.. gcc auto detects assembly files (extension *.s is the standard) and passes them over to it's own assembly compiler, "as". i've got "phxass" too but i cant get make to let me use it for some reason, bizzare.
NEXT!
-
Which is why I said that there might be an option. Only offering up possibilities.
-
yer, well it starts off with something like "Assembler Output:" before giving me all the errors. i'm half way now to figuring phxass out now. though i suspect i need to use it for the intermidiate assempler->object for the gcc c compiled files also. though i wouldnt know how to do that either!
-
I think the assembler format accepted by as is a bit different from that accepted by PhxAss. Also, the GNU linker needs a.out format object files as input, whereas PhxAss generates Amiga-native hunk format files. I don't know if there's any solution to this problem. Not accepting hunk files has been one of the main problems with Amiga GCC for a long time.
If you still have problems with comments, apparently gcc accepts C++ comments as long as -ansi or -traditional aren't used.
-
well, i havent got as far as the hunk stage, as i'm still stuck at the assembly.s file stage. i first thought it might have been a pedantic syntax error. e.g. not having the commands at the first tab, or having lower case instructions instead of uppercase. but that's about my limit of assembly knowledge! really.
my // comments are accepted by gcc330, which is what i'm using now
-
again, i'm lurching along one inch at a time. if i manually instruct phxass to compile a filename.s file then it's happy to do so. howevery i get a bunch of errors relating to FUNCDEF. from what i can gather i need a funcdef macro, well there's one in libraries.i thus
FUNCDEF MACRO
_LVO\1 EQU FUNC_CNT
FUNC_CNT SET FUNC_CNT-6
FUNC_CNT EQU LIB_USERDEF
ENDM
which doesnt do the job, phxass simply says "unkown directive" for each line.
my other problem is somehow getting phxass and gcc's make to coexist so i dont have to manually do each .s file. and i still don't know if there will be issues with phxass's outputs and gccs.
-
To continue this old thread....
I'm having the same kind of issues as this guy was. In theory you should just be able to add assembler sources directly to a project in StormC V4 when using the gcc compiler but that doesn't work for me (or him).
So now I'm using PhxAss to compile the assembly files to object files and adding them to my StormC project. I then have to use a special header file declaration as follows:
Code:
#define REG(reg,arg) arg __asm(#reg)
void setVol (REG(d0, int vol));
This works great as long as the project is in plain C but if I want to create a C++ project I get linker errors (adding extern to function definition doesn't help).
Anyone got any ideas?
-
#define REG(reg,arg) arg __asm(#reg)
I'm not sure if stormgcc (especially c++) like the __asm bit. It might work if you remove it.
x303 :D :D :D
-
Nope, that gives a syntax error :(
-
Update: Seems to work with a 'simple' prototype
eg void setVol(int vol);
-
Here are some links to help with installing GCC on Amiga :
http://amidevcpp.amiga-world.de/index.php?HR_LANG=english
http://code.google.com/p/guidetoamigacompatibleprogramming/source/browse/trunk/english/CAP_2.txt
Developer Winuae hardfile, working gcc, assembler
http://www.innoidea.hu/subsites/amiga/developer/FILES/HardFiles/gcc111.zip
Real amiga
http://www.innoidea.hu/subsites/amiga/developer/FILES/HardFiles/gcc111-files.tgz
Cross compile using VS
http://utilitybase.com/article/show/2008/05/12/240/Cross+Compiling+for+OS4+or+OS3+using+MS+Visual+Studio+2005
OS4 cross compile
http://utilitybase.com/article/show/2007/06/23/231/Installing+an+AmigaOS+4+cross+compiler
-
is that right?
it's c code (adoom)
it says "parse error before /" on line 1 of every file.
yes i know // is c++ but it's also c99
If you want that the gcc assembler gas support C style defines and includes, you need name in makefile the filename extension a capital s.
so assembly.S should support in C comment syntax.
-
To continue this old thread....
(snip)
Anyone got any ideas?
I got around all my C++ / asm combination problems by using inline C++ functions that call asm() construct directly.
For example
inline uint32 swap32(uint32 val)
{
if (__builtin_constant_p(val)) {
val = val<<16 | val>>16;
val = ((val&0x00FF00FF)<<8) | ((val&0xFF00FF00)>>8);
} else {
asm(
"rol.w #8, %0\n\t"
"swap %0\n\t"
"rol.w #8, %0"
: "=d"(val)
: "0"(val)
: "cc"
);
}
return val;
}
You can (and I have) used the asm() statement inside an inline C++ function to jsr to an externally referenced function written in assembler. Just make sure the variables passed to your inline function are loaded into the correct registers inside the asm() just before you jsr and add those registers to the clobber list so the compiler knows your call is going to trash them.
-
Quick update (for reference):
So now I'm using PhxAss to compile the assembly files to object files and adding them to my StormC project. I then have to use a stub declaration as follows to call the underlying assembler function:
void c2p1x1_cpu3blit1_queue_stub(UBYTE *c2pscreen, UBYTE *bitplanes) {
UBYTE * _c2pscreen = (c2pscreen);
UBYTE * _bitplanes = (bitplanes);
register UBYTE * __c2pscreen __asm("a0") = _c2pscreen;
register UBYTE * __bitplanes __asm("a1") = _bitplanes;
__asm volatile ( "jsr _c2p1x1_cpu3blit1_queue" : : "r" (__c2pscreen), "r" (__bitplanes) : "d2", "d3", "d4", "d5", "d6", "d7", "a2", "a3", "a4", "cc", "memory");
}