Path: chuka.playstation.co.uk!chuka.playstation.co.uk!chuka.playstation.co.uk!not-for-mail From: Lewis_Evans@Playstation.sony.com Newsgroups: scee.yaroze.freetalk.english Subject: ANSI C code Date: 11 Mar 1998 10:52:43 -0000 Organization: Sony Computer Entertainment Europe - 119.SS5 Lines: 46 Sender: news@chuka.playstation.co.uk Message-ID: <6e5qdr$p7b1@emeka.playstation.co.uk> Reply-To: Lewis_Evans@Playstation.sony.com NNTP-Posting-Host: emeka.playstation.co.uk by mail2.fw-sj.sony.com (8.8.8/8.8.8) with ESMTP id CAA13561 for ; Wed, 11 Mar 1998 02:57:26 -0800 (PST) From: Lewis_Evans@Playstation.sony.com To: news@playstation.co.uk Owing to how I learnt C (without a textbook) I've been happily producing yaroze code that doesn't seem to work on CodeWarrior, I assume because my code isn't ANSI standard. What precautions do I have to take to ensure codewarrior will compile my code? I've found out about two... Both Net Yaroze compilers (GNU and CodeWarrior) are very close to being fully ANSI C compliant. However, this really doesn't sound like the cause of the trouble. when using #define, the defined part must be in brackets, and at the end of IF and FOR loops, it seems to not want a semicolon after the final closing brace. Not sure what you mean about brackets; for simple constants, #define FALSE 0 #define TRUE 1 but for macros, yes, eg #define abs(x) x >= 0 ? x : -x will give problems with eg abs(y-5) and other expressions since the expressions are just shoved into the macro and precedence becomes tangled. With and , the syntax is thus if (expression) { // consequent action code here } the binds with the very next code block (eg single statement) it finds, so if (expression) ; means 'if expression true, do the semicolon', ie do nothing no matter what. binds in the same way, so for (/*conditions*/) ; means (for .....) do nothing, since the semicolon has no effects. Lewis