Question

I am actually working with some old software of my company and I try to figure out how to make stuff works properly.

After some database editing, I got a software that gives me some *.C files to compile later to get a environment simultation tool.

My main problem is that I did not manage to get any compilation working. I am facing 2 mains errors :

Error : C2097 : Illegal Initialization

and

Warning C4047 'Initializing' : different levels of indirection.

I started my research to understand about those levels of indirection. I think I understand the thing trying to save pointer of pointer with pointer of data etc.

The code is not mine. All of those in computer generated with an application. The point is that people who developped all those stuff are retired.

Here are the main parts of the code:

ST_FAMI.H

struct  bit
{
    unsigned bit0   :1;
    unsigned bit1   :1;
    unsigned bit2   :1;
    unsigned bit3   :1;
    unsigned bit4   :1;
    unsigned bit5   :1;
    unsigned bit6   :1;
    unsigned bit7   :1;
    unsigned bitnul :8;
};

union etatbit
{
    int VETAT ;
    struct bit VBIT;
};

typedef struct
{
    union etatbit VACTUEL;
    union etatbit VANTERI;
    int VISUELEM;
    int TMPCARTC;
} elemoct;


struct FAMI
{
    char  *PLIBFAMI;                
    int   PNBELEM ;                 
    char  PTYPFAMI[2];              
    int   PMSGRANCOM[2];    
    char  PNBLIUTI;                 
    char  VETAVISFAMI;
    char  VNUMLIU;
    char  VPAGFAMI;
    unsigned char  PNUMPSBAC;
    unsigned int   PNUMGRPA[5];
    char  PNUMVOIE;

    elemoct   *Tptelmsg;            
 };

My M1L0PS1.C File :

line 1:  #include "st_fami"
line 2: 
line 3:  elemoct  E_L0PS1Pq0[64];
line 4:  struct FAMI L0PS1Pq0 =
line 5:  {"L0PS1Pq0",   
line 6:  64,                
line 7:  {'M','P'},      
line 8:  {'T',0 },       
line 9:  17,             
line 10: 0,              
line 11: 0,              
line 12: 0,              
line 13: 1,              
line 14: 0,              
line 15: 0,              
line 16: E_L0PS1Pq0};    

Error Log :

M1L0PS1.C
M1L0PS1.C(16) : error C2097: illegal initialization
M1L0PS1.C(16) : warning C4047: 'initializing' : different levels of indirection

My Question : I dont get the Levels of Indirection Error. I tried de give my initialization differents data like : &(E_L0PS1Pq1[0]) (Adress of the element 0) but ait doesnt work as intended.

What is wrong with this code? I am note a proper C developper. I used to do some C++ or Java and my knowledge of pointers is a bit biased because of those less strict languages. I am compiling with "Microsoft (R) C Optimizing Copiler Version 5.10".

Sorry my english and Thanks if anyone read through the whole text ! :D

Was it helpful?

Solution

PNUMGRPA[5] is an array. You attempt to initialize it with 0 rather than {0}.

OTHER TIPS

You don't initialize the PNUMGRPA member properly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top