Error compiling against PSXLIB

All other SDK help, questions and information
Post Reply
jman
Rookie Programmer
Rookie Programmer
Posts: 110
Joined: August 13th, 2013, 7:58 am

Error compiling against PSXLIB

Post by jman » October 21st, 2013, 8:28 am

Hello,

I'm having a weird compile error if I use Orion_'s wrapper (PSXLIB).

The following code (just a proof):

Code: Select all

#include "System.h"

int main(void)
{
	System_Init(MODE_PAL, VMODE_16BITS, 320, 240, GsNONINTER, 0);
	short sprt_x;
	return 0;
}
Produces this error:

Code: Select all

test.c: In function `main':
test.c:6: parse error before `short'
Removing the System_Init() or moving up sprt_x declaration apparently "fixes" the problem.
I tried digging a bit, compiling PSXLIB with -Wall flag (which I usually do): more errors like that came out.

What could be the problem? Orion_, I hope you're around :)

Thanks

User avatar
Shendo
C Programming Expert
C Programming Expert
Posts: 238
Joined: March 21st, 2012, 4:34 am
I am a: Programmer
Motto: Never settle
PlayStation Model: SCPH-9002
Location: Croatia, EU

Re: Error compiling against PSXLIB

Post by Shendo » October 21st, 2013, 11:51 pm

You should declare all variables before calling any functions.
My PS1 consoles: 2 x SCPH-1002, SCPH-5552, SCPH-7002, 4x SCPH-9002, 2 x SCPH-102.
Dev console: SCPH-9002, MM3 - 7 wire modchip, PAL color mod, CH340 serial cable addon.

jman
Rookie Programmer
Rookie Programmer
Posts: 110
Joined: August 13th, 2013, 7:58 am

Re: Error compiling against PSXLIB

Post by jman » October 22nd, 2013, 12:33 am

Shendo wrote:You should declare all variables before calling any functions.
Errm... what? :)

It looks to me a bit of an awkard piece of advice.

Yagotzirck
Serious PSXDEV User
Serious PSXDEV User
Posts: 89
Joined: July 17th, 2013, 2:37 am

Re: Error compiling against PSXLIB

Post by Yagotzirck » October 22nd, 2013, 6:07 am

There's nothing "awkward" in what he said, C89 forces variables to be declared before instructions.
long story short:

Code: Select all

int main(void)
{
   short sprt_x;
   System_Init(MODE_PAL, VMODE_16BITS, 320, 240, GsNONINTER, 0);
   
   return 0;
}

jman
Rookie Programmer
Rookie Programmer
Posts: 110
Joined: August 13th, 2013, 7:58 am

Re: Error compiling against PSXLIB

Post by jman » October 22nd, 2013, 8:17 am

Yagotzirck wrote:There's nothing "awkward" in what he said, C89 forces variables to be declared before instructions.
Interesting. So ccpsx adheres to the C89 standard (at least in this respect). I dind't know that nor I've found any mention in the docs about a C89 compliancy (I've never met a compiler with that constraint - not that I'm that knowledgeable in C language nor compilers for that matter, I've always worked/crosscompiled with recent version of GCC).

But thanks for clarifying this!

Yagotzirck
Serious PSXDEV User
Serious PSXDEV User
Posts: 89
Joined: July 17th, 2013, 2:37 am

Re: Error compiling against PSXLIB

Post by Yagotzirck » October 23rd, 2013, 12:37 am

gcc allows a lot of non-standard operations, unless a specific standard is specified(e.g. if you add the -std=c89 parameter, variables must be declared before instructions on gcc as well, among the other things)
I'm not completely sure if ccpsx fully adheres to c89 standard, but it's the most plausible option considering it's way too outdated to support c99(which is the C standard allowing declaration of variables after instructions, variable length arrays and other fancy stuff)
But thanks for clarifying this!
you're welcome :)

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest