Author: Alexander Kure
Date: 13:55:17 08/29/05
Go up one level in this thread
On August 29, 2005 at 16:15:30, Gian-Carlo Pascutto wrote:
>typedef struct {
> int a;
> int b;
>} data_t;
>
>typedef struct
>{
> volatile data_t datalist[CONSTANT];
>}
>bigstruct_t;
>
>data_t get_data(int i)
>{
> return globalpointer->bigstruct.datalist[i];
>}
>
>Apparently GNU C++ refuses to compile this in C++ mode (works fine when
>compiling as C code). Any proposed fixes?
>
>a.c: In function `data_s get_data(int)':
>a.c:443: error: no matching function for call to `data_s::._47(volatile
> data_s&)'
>b.h:133: error: candidates are: data_s::._47(const data_s&)
>
>--
>GCP
Dear GCP,
A struct in C++ is declared the same way as a class (since a struct is a class
with the only notable difference that the default member access is public
instead of private):
struct data_t
{
int a;
int b;
};
Though in your example this should not hurt your compiler.
The problem seems to be the volatile declared attribute in
struct bigstruct_t
{
volatile data_t datalist[CONSTANT];
};
Visual C++ .Net 2003 issues a compile error:
'return' : cannot convert from 'volatile data_t' to 'data_t'
No copy constructor available for struct 'data_t' or constructor
attempts to perform illegal conversion to non-__gc reference
I am not sure if it makes sense for a class/struct attribute to be declared
volatile, but then I am not too familiar with it. I'd just omit it here.
Hope this helps.
Alex
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.