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

Re: [MiNT] gcc-4.4.3 usage



Ole Loots wrote:
layout.c: 1239: warning: implicit declaration of funtion 'typeof'
layout.c: 1239: warning: nested extern declaration of 'typeof'
...
width = min(max(box->min_width, available_width),
				box->max_width);

min is defined this way:
#define min(a,b) ((a)<(b)?(a):(b))

First, which compiler are you using ?

I believe you have not found the correct definition of min().
My cross-compiler is shipped with the PML math library, and there is that in <math.h>:

#  ifndef max
# define max(x,y) ({typeof(x) _x=(x); typeof(y) _y=(y); if (_x>_y) _y=_x; _y;}) # define min(x,y) ({typeof(x) _x=(x); typeof(y) _y=(y); if (_x<_y) _y=_x; _y;})
#  endif

This is where that famous typeof is.
However, it should be OK.
Note that it generates only a warning, not an error.
And typeof is a GCC built-in (like sizeof), it should not be seen as a function. Maybe your project use special compilation settings ?

I have made some tests with GCC 4.5.0.
I can see a similar warning only if I compile a small program with -Wall -ansi. However, it fails with other errors.

Anyway, those definitions in math.h are not good. If these min and max definitions should be kept, they should use __extension__ and __typeof__ to avoid that kind of problems.

To solve your problem temporarily: in layout.c, after all the includes put the following lines:
#undef min
#define min(a,b) ((a)<(b)?(a):(b))
#undef max
#define max(a,b) ((a)>(b)?(a):(b))

Well, basically you have some hints, you should be able to fix your problem while <math.h> is not yet fixed.

--
Vincent Rivière