Hi, IMO the problem is created by the C standard in the first place. They require a char to be promoted to an int, but do nothing to prevent problems when passing a long. They should either have required it to be cast down to an int as well, cast everything up to the largest supported integer type or just pass everything as is. I personally prefer the latter. But we have to make do with the standard as it is.
The advantage of using __nopromote() would be that you could make a macro for it to get rid of it if it gets in the way. OTOH the extra cast has no effect on any other compiler that always promotes to int. It's the varargs function that needs to be modified to the actual compiler behavior. Rereading above reasoning, I don't know where I stand in this, except that the standard is stupid. Maarten > What I really don't like about the current behaviour of sdcc here is > that it breakss standard-conforming programs. There are two other > differences between standard C and the default dialect in sdcc, but > those just allow something that would be a syntax error in standard C. > But omitting integer promotions on arguments of vararg functions changes > the semantics. > > How about having a way to pass unpromoted chars to vararg functions that > uses a different syntax? Maybe something like > > f(x, __nopromote(c)); > > instead of > > f(x, (char)c); > > Philipp ------------------------------------------------------------------------------ Transform Data into Opportunity. Accelerate data analysis in your applications with Intel Data Analytics Acceleration Library. Click to learn more. http://pubads.g.doubleclick.net/gampad/clk?id=278785111&iu=/4140 _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user