Re: [cc65] Problems with va_copy

From: Spiro Trikaliotis <ml-cc651trikaliotis.net>
Date: 2005-12-11 14:26:42
Hello Uz,

* On Sun, Dec 11, 2005 at 02:07:49PM +0100 Ullrich von Bassewitz wrote:

> To work around problems with some compilers having snprintf and others
> not having it, I've added my own implementation some time ago. To do
> this, I needed a facility to copy a va_list, so I added a va_copy.h
> file which includes this facility for compilers that don't have it.

Oh, this was the reason for <dnc8md$8j3$1@moppi.musoftware.de>?
 
> It is my philosophy, that if you have to add too many #ifdefs to a
> file, you're doing something wrong. Portable code does not need
> #ifdefs (this is contrary to popular belief, which says the more
> #ifdefs you have, the more portable your code is).

This is true. Anyway, I ask if it would not be better to use some other
approach:

1. Define some function/macro/whatever called "my_va_copy()"

2. Let some script (./configure comes to find) try to determine if
   va_copy() is available and working on your compiler. If so, let
   my_va_copy() call va_copy(). If not, let my_va_copy() be your own
   implementation.

BTW: autoconf helps very much here!

Even if you want to ommit step 2, at least, you could let the user
decide if he wants to use the va_copy() of the compiler ("$CC -D
HAVE_VA_COPY").

> The advantage of this approach is that the problem is now the problem
> of the compiler. If it claims to be C99 conformant, it must have
> va_copy, if it doesn't claim to be a C99 compiler it is not allowed to
> have va_copy. If neither is true, the compiler is broken.

I'm no C expert, but: Isn't a compiler (or its standard libraries)
allowed to define more symbols than the standard gives?

> If you're compiling cc65 yourself, I would request that to test this
> change and tell me if it works.

Is this change already in today's snapshot?

Regards,
   Spiro.

-- 
Spiro R. Trikaliotis
http://www.trikaliotis.net/
http://cbm4win.sf.net/
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Sun Dec 11 14:27:08 2005

This archive was generated by hypermail 2.1.8 : 2005-12-11 14:27:11 CET