Pages: [1]   Go Down

Author Topic: C Compilers on Mac vs. C Standards  (Read 1477 times)

Jubadub

  • 256 MB
  • *****
  • Posts: 431
  • New Member
C Compilers on Mac vs. C Standards
« on: June 16, 2024, 09:23:26 AM »

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: [Select]
int hi;
hi = 2;
int hiAgain; /* COMPILER IS DEAD AS SHEIT */

Working code:

Code: [Select]
int hi;
int hiAgain;
hi = 2;

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?
Logged

joevt

  • 64 MB
  • ****
  • Posts: 99
  • New Member
Re: C Compilers on Mac vs. C Standards
« Reply #1 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?
Logged

Jubadub

  • 256 MB
  • *****
  • Posts: 431
  • New Member
Re: C Compilers on Mac vs. C Standards
« Reply #3 on: June 16, 2024, 09:52:22 PM »

Which Metrowerks CodeWarrior version? IDE version?

Isn't there an ANSI strict option or something to change this?

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. :)
Logged

Jubadub

  • 256 MB
  • *****
  • Posts: 431
  • New Member
Re: C Compilers on Mac vs. C Standards
« Reply #4 on: June 24, 2024, 12:14:36 AM »

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.
Logged
Pages: [1]   Go Up
 

Recent Topics