Menu

#1667 parameter of same static functions name in different files

closed-fixed
6
2013-05-25
2010-08-02
ss77
No

Tried the build 20100730 version 2.9.7 #5896. I have these observations.
Looks like the name of parameter passed are not local.
I do not have the same problem when using version 2.9.0
//-------------------------------------------------
// src1.c
static unsigned char locstate;
static void doRdyGetNext( unsigned char state, unsigned char *msg ) {
while(*msg) {
msg++;
}
locstate = state;
}

void src2_func ( void ) {
doRdyGetNext(1,"Hai");
}
//-------------------------------------------------
// src2.c
static unsigned char locstate;
static void doRdyGetNext( unsigned char state, unsigned char *msg ) {
while(*msg) {
msg++;
}
locstate = state;
}

void src2_func ( void ) {
doRdyGetNext(1,"Hai");
}
//-------------------------------------------------
// main.c
void src1_func ( void );
void src2_func ( void );

void main ( void ) {
src1_func();
src2_func();
}
//-------------------------------------------------
// Get linker error
Multiple definition of _doRdyGetNext_PARM_2
Multiple definition of LdoRdyGetNext$msg$1$1

Discussion

  • Philipp Klaus Krause

    Looks like a duplciate of #1477149.

    Philipp

     
  • Philipp Klaus Krause

    • priority: 5 --> 6
    • status: open --> open-duplicate
     
  • Maarten Brock

    Maarten Brock - 2011-04-24

    The fact that 2.9.0 did not present this problem is due to this version being unable to distinguish real duplicates when they are at the same offset within the module. SDCC would have mapped all use of this parameter to the first occurence and the second would stay unused. If you call src1_func from doRdyGetNext in src2.c you will see its contents getting overwritten.

    SDCC 2.9.7 can detect this problem and reports it.

    Though related to 1477149 it is not exactly the same as this one is about parameters and 1477149 is about file static variables. Those variables had a label with double colon (::) and these parameters had a .globl declaration.

    Fixed in SDCC 3.0.2 #6464.

     
  • Maarten Brock

    Maarten Brock - 2011-04-24
    • milestone: --> fixed
    • assigned_to: nobody --> maartenbrock
    • labels: 355283 --> mcs51(8051) target
    • status: open-duplicate --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB