[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [OT] gcc-warnings



On Tue, Oct 17, 2000 at 05:03:35PM +0200, Daniel Reuter wrote:
> Hello there,
> 
> I never quite understood the following warning message from gcc:
> 
> sourcefile.c: linenumber: warning: assignment makes pointer from integer
> without a cast

Hi,

this basically means exactly what it says:

at that specific point in your code you have an assignment where an
integer (a function return value, expression or whatever) is being
assigned to a pointer, without anyone telling the compiler what type
of pointer your integer is supposed to represent.

It's a warning and not an error, because under various circumstances
integers and pointers are assigment-compatible (at the machine-level,
both are just integer numbers).

Although there are usually better ways of doing it, if you really need
such an assigment, you have to tell the compiler precisely what you
mean -- by using a type cast, e.g.

  double * p;
  p = (double *) func_that_returns_int();
      ^^^^^^^^^^
Keep in mind, however, that in this case you are fully responsible
for what you do. You can no longer rely on type-checking assistance
from the compiler...

HTH,
Erdmut


-- 
Erdmut Pfeifer
science+computing gmbh

-- Bugs come in through open windows. Keep Windows shut! --



Reply to: