0

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

Jonathon Reinhart
  • 132,704
  • 33
  • 254
  • 328
  • Please edit your question to include the *complete* and *unedited* error log. Also show some more complete code (preferably a so called [SSCCE](http://sscce.org/)), including pointing out where in that source the errors are about. – Some programmer dude Mar 10 '14 at 14:49
  • Edited for the Etabit question. I'll reformat my question to me more precise. – user3402033 Mar 10 '14 at 14:56
  • It compiles fine here. I think your compiler is too old. – Jabberwocky Mar 10 '14 at 15:06
  • 1
    @MichaelWalz I dont think `unsigned int PNUMGRPA[5] = 0;` will compile fine on any conforming C compiler. I think your compiler is too old :) – Lundin Mar 10 '14 at 15:15
  • This is a great answer ;) I am working on a DOS computer. But everything should work on it because the software i'm using are at least 20yo (The compiler .exe file is from the 7th march 1988 :D) I'll look for another compiler version but I am a bit affraid of compatibility issues. Everything looks 'frozen' because software are working together and anyname change breaks everything (Even path.. everything is hardcoded) I scratched my head for 2 days before daring asking my question here. – user3402033 Mar 10 '14 at 15:16
  • @user3402033: actually it doesn't compile here either, I only checked with the very partial informatinon in your question before youhave ve edited it. – Jabberwocky Mar 10 '14 at 15:37
  • The {0} seems to solve some stuff. I will now take care of not focusing on error line but on the global thing. – user3402033 Mar 10 '14 at 15:43

2 Answers2

2

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

Lundin
  • 195,001
  • 40
  • 254
  • 396
1

You don't initialize the PNUMGRPA member properly.

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621