lppier
lppier

Reputation: 1987

Cannot include Accelerate Header in iOS C++ code

I have some code that I want to call vDSP upon. This is a C++ file, in an Xcode project. The main project is in Objective C. Whenever I do

#include <Accelerate/Accelerate.h>  

It gives me a lot of errors.

#if defined(__cplusplus)
#pragma once

#include <Accelerate/Accelerate.h> // <-- error
#include "oscillator.h"


namespace synth {
class CQBLimitedOscillator : public COscillator
{
    float dOuts[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
public:
    CQBLimitedOscillator(void);
    ~CQBLimitedOscillator(void);

    // --- init globals
    inline virtual void initGlobalParameters(globalOscillatorParams* pGlobalOscParams)
    {
        // --- always call base class first to store pointer
        COscillator::initGlobalParameters(pGlobalOscParams);

        // --- add any QBL specifics here
    }

    // -- parallel proqcess 4 sawteeth
    inline void doSawTeeth(float* dOutsIn, float dModulo, float dInc) {

        float scalar2Val = 2.0f;
        float scalar1Val = -1.0f;

        // -- 2.0f*dValue - 1.0f
        vDSP_vsmsa(dOutsIn, 1, &scalar2Val, &scalar1Val, dOutsIn, 1, 4);

    }

Errors

Upvotes: 1

Views: 941

Answers (1)

lppier
lppier

Reputation: 1987

One of the files included in oscillator.h had this:

#include "math.h"

Changing it to

#include <cmath>

did the trick. Accelerate uses the math library in this way (cmath) as well.

Upvotes: 2

Related Questions