I have this piece of code wont compile when I write:
sdcc test.c -mstm8 --std-sdcc11 --all-callee-saves --verbose --stack-auto
--fverbose-asm  --float-reent --no-peep --debug
I get error "machine specific addressing or addressing mode error". Its
look like the generated assembly is not correct. Is this a bug or I am
missing something?
here is test.c:

int func(void *var,int val);
typedef int (*SetVal)(void *, int);
typedef struct {
                int val;
                SetVal setval;
                } my_struct;
int main()
{

    my_struct str1 = {0,func};
    my_struct str2 = {0,func};
    str1.setval(&str1,11);
    str2.setval(&str2,5);
    return 0;
}
int func(void *var,int val)
{
    my_struct *tmp = (my_struct*)var;
    tmp->val = val;
    return 0;
}

strangely, when I change is as following it compiles :

int func(void *var,int val);
typedef int (*SetVal)(void *, int);
typedef struct {
                int val;
                SetVal setval;
                } my_struct;
my_struct str1 = {0,func};
int main()
{
    my_struct str2 = {0,func};
    str1.setval(&str1,11);
    str2.setval(&str2,5);
    return 0;
}
int func(void *var,int val)
{
    my_struct *tmp = (my_struct*)var;
    tmp->val = val;
    return 0;
}
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to