Post Go back to editing

CC1134 error in CCES C++ struct's pm & dm member

dear ADI admins,

i'm using adsp-21479 processor, it's fine to execute below code in C but i'm not able to execute when i change the postfix from .c into .cpp. there's cc1134 error message displayed in console and sadly i can't remove the pm/dm from the declaration, in order to use biquad function inside <filters.h> i need my structure member declare in pm section.

header.h

#progma once

#ifndef NSECTIONS
#define NSECTIONS (1)
#endif

#ifndef NSTATE
#define NSTATE (2*NSECTIONS)
#endif

typedef struct filter FILTER;
struct filter
{
    float state[NSTATE];
    float pm coeffs[5*NSECTIONS];
};

FILTER* init(void* address);

source.cpp

#include header.h
#include <filters.h>

FILTER* init(void* address)
{
    if (address == NULL) return NULL;
    FILTER* self = (FILTER*)address;

    self->coeffs[0] = 0.9849995433380051;
    self->coeffs[1] = -1.9699990866760102;
    self->coeffs[2] = 0.9849995433380051;

    self->coeffs[3] = -0.9702240460889019;
    self->coeffs[4] = 1.9697741272631186;

    for (int i = 0; i < NSTATE; i++)
    {
        self->state[i] = 0.0;
    }

    return self;
}

regards,

kweiwen



typo
[edited by: kweiwen at 5:50 PM (GMT -4) on 11 Aug 2021]
  • Hi Kweiwen, 

    This looks like there is a bug in the C compiler, as you should not be able to use the PM qualifier inside a struct. Struct members are required to be continuous in C/C++. The error you are seeing with C++ is correct, as the state member will be placed in DM, so won't be continuous with the coeffs member. If you really need to store the coeffs and state within the same struct then you may be able to use pointers to each array stored in a struct, but you will have to declare the arrays independently to get them in seperate PM/DM memory spaces. Hopefully this is helpful.

    Best,

    Calum