Re: [cc65] return vs. exit()

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2009-10-19 00:11:12
Hi!

On Sun, Oct 18, 2009 at 11:54:06PM +0200, silverdr@wfmh.org.pl wrote:
> Danke! Seems to work with the snapshot.

Finishing/fixing the code for attributes was overdue anyway. You can now also
use "__attribute__((unused))" on a symbol to avoid warnings. And there will be
more attributes in the future.

> assertion.c:46: warning: unused parameter 'A'

This one is known and harmless, but ...

> ar65: Warning: Replacing module `systime.o' by older version

... this is unknown to me, so I would suggest checking the reason.

> Should something as simple as the above work? It doesn't seem to.
> Target is C64 so the IO should be there, right?

IO is there, the problem is in the call to fopen. "ro" is an invalid mode, and
the standard says:

  "The argument mode points to a string. If the string is one of the
  following, the file is open in the indicated mode. Otherwise, the behavior
  is undefined."

Just change the mode to "r" and the program should work. As a general rule:
Checking return codes from functions will ease your life. Adding

        if (fh == 0) {
            perror ("fopen");
            return EXIT_FAILURE;
        }

after the call to fopen() would have printed:

        fopen: Invalid argument

which might have been helpful.

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz@musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Mon Oct 19 00:14:18 2009

This archive was generated by hypermail 2.1.8 : 2009-10-19 00:14:20 CEST