In an C application, the following code is present.
#include <stdlib.h>
#include <string.h>
typedef struct
{
/*! matrix ID */
int id;
/*! number of rows */
int num_rows;
/*! number of columns */
int num_cols;
union {
float *matrix;
float *vector;
};
} PpetKeviParams;
typedef struct {
char DB_char;
int DB_index;
float DB_val;
PpetKeviParams outvec;
} DBType;
int main(void)
{
DBType *p_DB=(DBType *)malloc( sizeof(DBType));
if (p_DB->outvec.vector == NULL) {
printf("\t\t\tp_DB->outvec.vector is NULL\n");
}
if(p_DB != NULL) {
free(p_DB);
}
return 0;
}
The above code is getting compiled and executed, as an independent application.
But, when the structure DBType
is used as part of a bigger application, the following line gives the error,
if (p_DB->outvec.vector == NULL) {
error: ‘PpetKeviParams’ has no member named ‘vector’**
The gcc version in the Linux machine is 4.1.1
The same code (bigger application) is getting compiled in gcc 4.6.2 machine.
I couldn't find the issue. Can somebody help?