Mac OS 9 Discussion > Development & Programming
C Compilers on Mac vs. C Standards
(1/1)
Jubadub:
In case anyone here with C knowledge can figure out this one: http://macintoshgarden.org/forum/c-compilers-mac-vs-c-standards
Summary of that thread is this:
Broken code:
--- Code: ---int hi;
hi = 2;
int hiAgain; /* COMPILER IS DEAD AS SHEIT */
--- End code ---
Working code:
--- Code: ---int hi;
int hiAgain;
hi = 2;
--- End code ---
According to ALL I could find on the ANSI C89 / ISO C90 and even ISO C99 standards, both snippets should have been valid code. Yet this happens with both CodeWarrior and Symantec. Anyone knows more about where this rule is coming from?
joevt:
Which Metrowerks CodeWarrior version? IDE version?
Isn't there an ANSI strict option or something to change this?
robespierre:
https://retrocomputing.stackexchange.com/questions/22096/why-couldnt-early-c-compilers-handle-variable-declarations-between-statements
Jubadub:
--- Quote from: joevt on June 16, 2024, 01:20:53 PM ---Which Metrowerks CodeWarrior version? IDE version?
Isn't there an ANSI strict option or something to change this?
--- End quote ---
Pro 6.3 and Pro 8.3.
There is a checkbox in CW, yes, but this happens regardless of it being checked or not. I tested.
Nonetheless, we got an answer in the Garden thread. The TL;DR is ANSI C89 discourages it, but doesn't outright prohibit it. Before, during K&R C First Edition era (1983) and maybe even earlier, it wasn't an issue. And the next redesigned standard, ISO C99, no longer discourages it AFAIK. So Symantec, Metrowerks (and Apple in MPW too, it seems) all treat it as an error (when it should actually be just a warning if even anything at all) within a scope.
@robespierre Somehow I can't view your response on Classila 9.3.4b. All that is rendered is a scrollbar?
EDIT: Nevermind, I saw the link being rendered without the scrollbar hiding it in the new theme when I was replying. Thank you for the link. :)
Jubadub:
For anyone else developing code using the CodeWarrior IDE on Mac OS 9 like me:
There's a well-hidden feature for commenting code with keyboard shortcuts, via an AppleScript provided in the official install. But there was no "uncommenting" counterpart. So I made one.
Works for C, C++, Java and Pascal. I didn't test the Pascal side, though, but it should work. Feedback is welcome. Script improvements, too, since both this and the official "comment" scripts don't highlight the commented/uncommented text after the action is done, and we also cannot Cmd+Z to undo them, both of which can be done in BBEdit 7.1.4.
Navigation
[0] Message Index
Go to full version