Re: unhappy with current.h

From: Richard B. Johnson (root@chaos.analogic.com)
Date: Tue Oct 15 2002 - 12:08:48 EST


On Mon, 14 Oct 2002, Daniele Lugli wrote:

>
> Try the following instead:
>
> // file shade1.cpp
>
> // excerpt from common.h
>
> #define current get_current()
>
> // my stuff
>
> struct {
> int any;
> int current[1000];
> } mine;
>
>
> // file shade2.cpp
>
> #include <stdio.h>
>
> // my stuff
>
> extern struct {
> int any;
> int current[1000];
> } mine;
>
> int main () {
> mine.current[999] = 1;
> printf ("%d\n", mine.current[999]);
> }
>
> g++ shade1.cpp shade2.cpp
>
> ./a.out => segmentation fault
>
> Regards, Daniele
>

It should have written a diagnostic which it does in C, not C++.

xxx.c:6: `get_current' declared as function returning an array
xxx.c:6: field `get_current' declared as a function

This () make all the difference. If you are trying to write kernel
drivers in C++, you will have more suprises. If not, you should
not be including kernel headers.

Cheers,
Dick Johnson
Penguin : Linux version 2.4.18 on an i686 machine (797.90 BogoMips).
The US military has given us many words, FUBAR, SNAFU, now ENRON.
Yes, top management were graduates of West Point and Annapolis.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Oct 15 2002 - 22:00:55 EST