Regarding structure

Hello I am trying to define a structure whose member is an array using the following syntax, but have been getting the error saying "Redefinition of structure, type mismatch  of "x". It works fine x is a matrix, is there any reason for that? Thanks Annesha

struct var_array {
array x;
};

1 Answer



0



The error "Redefinition of structure" means that you have created a structure definition and then you are trying to change it to something else. This prevents you from having two different structures with the same type-name but different members in your program which could cause problems when part of your program expected one definition of var_array and another part of your program expected a different definition of var_array. For example, this will reproduce your problem:

struct var_array {
   matrix x;
};

struct var_array {
   array x;
};

It does not matter if the matrix version is first or the array version, you will get an error in either case, because you are only allowed to have one definition for your var_array structure in your program.

You can clear out the previous definition of var_array with the new command. After executing new you can create a new definition of var_array.

If you want to use this structure in multiple programs (and are using GAUSS 13.1 or later), you can create a file that contains only the definition of var_array and add it to your user library and then it will always be available for any program you write.

aptech

1,773

Your Answer

1 Answer

0

The error "Redefinition of structure" means that you have created a structure definition and then you are trying to change it to something else. This prevents you from having two different structures with the same type-name but different members in your program which could cause problems when part of your program expected one definition of var_array and another part of your program expected a different definition of var_array. For example, this will reproduce your problem:

struct var_array {
   matrix x;
};

struct var_array {
   array x;
};

It does not matter if the matrix version is first or the array version, you will get an error in either case, because you are only allowed to have one definition for your var_array structure in your program.

You can clear out the previous definition of var_array with the new command. After executing new you can create a new definition of var_array.

If you want to use this structure in multiple programs (and are using GAUSS 13.1 or later), you can create a file that contains only the definition of var_array and add it to your user library and then it will always be available for any program you write.


You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.

Try GAUSS for 14 days for FREE

See what GAUSS can do for your data

© Aptech Systems, Inc. All rights reserved.

Privacy Policy