Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Relax my C compiler?

0 views
Skip to first unread message

!**?#!#$

unread,
Jul 10, 1998, 3:00:00 AM7/10/98
to
> ==========================================
> "net.c", line 93.22: 1506-280 (E) Function argument assignment between
> types "const char*" and "unsigned char*" is not allowed.
>
> "msqld.c", line 191.25: 1506-280 (E) Function argument assignment
> between types "void(*)(int)" and "void(*)()" is not allowed.

If you're sure the source is okay, you can use a cast of something like

x = y;

into

x = (unsigned char*)(y);

or

f(a)

into

f((void(*)(int))(a))

depending exactly what construct is being flagged.

--
The fire cools and fear returns; | - smr
his step is weak and stomach churns. | smj...@my-dejanews.com
The spectres spell in speeches fell; | www.geocities.com/SoHo
their hatred hounds and horror burns.| /Studios/5079/index.html

Stephen Baynes

unread,
Jul 10, 1998, 3:00:00 AM7/10/98
to
Kaz Kylheku wrote:
>
> In article <35A52FEE...@cac.psu.edu>, H SUN <hx...@cac.psu.edu> wrote:
> >Dear Sir,
> >
> >I tried to install mSQL 2.0.4 on IBM AIX-4.2-RS6000, but failed. I
> >always got such error messages:
> >==========================================

> >"msqld.c", line 191.25: 1506-280 (E) Function argument assignment
> >between types "void(*)(int)" and "void(*)()" is not allowed.
>

> This may a compiler bug. The two types are in fact compatible function types,
> and hence pointers to them are compatible as well. The one on the left is a
> pointer to a function returning nothing having a single argument of type int.
>
> If the compiler refuses to translate the program on grounds of this
> assignment, it is not acting as an ANSI C compiler, because ANSI C
> permits the conversion without requiring a cast. Try giving it options to make
> it behave like an ANSI C compiler.
>

I would disagree. They are not compatible types. The first is a pointer
to a prototyped function that takes one integer parameter, the second
is a call to an unprototyped function. If the unprototyped function takes
one integer parameter then you a probably safe to intermix them, but the
compiler does not know that. Off the top of my head, I can't even remember
if the standard requires that prototyped and non-prototyped functions
have to have the same calling convention.

[Crossposting added to comp.std.c for expert opinion.]

--
Stephen Baynes CEng MBCS Stephen...@soton.sc.philips.com
Philips Semiconductors Ltd
Southampton SO15 0DJ +44 (01703) 316431
United Kingdom My views are my own.
Do you use ISO8859-1? Yes if you see © as copyright, ÷ as division and ½ as 1/2.

Clive D.W. Feather

unread,
Jul 13, 1998, 3:00:00 AM7/13/98
to
In article <35A61A98...@soton.sc.philips.com>, Stephen Baynes
<stephen...@soton.sc.philips.com> writes

>>>"msqld.c", line 191.25: 1506-280 (E) Function argument assignment
>>>between types "void(*)(int)" and "void(*)()" is not allowed.
>I would disagree. They are not compatible types.

And that's it. They are not pointers to compatible types, and therefore
the implicit conversion is forbidden and a diagnostic is required.

If an explicit cast was there, it would be allowed.

>Off the top of my head, I can't even remember
>if the standard requires that prototyped and non-prototyped functions
>have to have the same calling convention.

No it does not. You should to cast back to the declared type before
calling, though the rules for handling mixes of prototypes and non-
prototypes might save you (I can't be bothered to check).

--
Clive D.W. Feather | Regulation Officer, LINX | Work: <cl...@linx.org>
Tel: +44 1733 705000 | (on secondment from | Home: <cd...@i.am>
Fax: +44 1733 353929 | Demon Internet) | <http://i.am/davros>
Written on my laptop; please observe the Reply-To address

Lawrence Kirby

unread,
Jul 14, 1998, 3:00:00 AM7/14/98
to
In article <89CJHsLl...@on-the-train.demon.co.uk>

cl...@linx.org "Clive D.W. Feather" writes:

>In article <35A61A98...@soton.sc.philips.com>, Stephen Baynes
><stephen...@soton.sc.philips.com> writes
>>>>"msqld.c", line 191.25: 1506-280 (E) Function argument assignment
>>>>between types "void(*)(int)" and "void(*)()" is not allowed.
>>I would disagree. They are not compatible types.
>
>And that's it. They are not pointers to compatible types, and therefore
>the implicit conversion is forbidden and a diagnostic is required.

They *are* pointers to compatible types. C90 6.5.4.3:

"For two function types to be compatible, both shall specify compatible
return types. Moreover...

...If one type has a parameter type list and the other type is specified
by a function declarator that is not part of a function definition and that
contains an empty identifier list, the parameter list shall not have an
ellipsis terminator and the type of each parameter shall be compatible with
the type that results from the application of the default argument
promotions."

"void ()" and "void (int)" fulfil these requirements and are therefore
compatible types. Hence pointers to these types are also compatible.

>If an explicit cast was there, it would be allowed.
>
>>Off the top of my head, I can't even remember
>>if the standard requires that prototyped and non-prototyped functions
>>have to have the same calling convention.
>
>No it does not. You should to cast back to the declared type before
>calling, though the rules for handling mixes of prototypes and non-
>prototypes might save you (I can't be bothered to check).

The types of the function called only has to be compatible with the
type of the function definition (promoted arguments and parameters have to
be compatible too of course) so this will work fine. For example I can write

int main(void)
{
puts("Hello, world.");
return 0;
}

The implicit declaration of puts here is not prototyped. The code is still
correct after adding declarations such as:

int puts();

or

int puts(const char *);

Indeed both can be added. For that to work they must be compatible so
that they can form a composite type.

--
-----------------------------------------
Lawrence Kirby | fr...@genesis.demon.co.uk
Wilts, England | 7073...@compuserve.com
-----------------------------------------


0 new messages