I would like to build in an error message which should be issued during compilation depending on the value of a variable.
I have defined following class:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
class rFFT : public QObject
{
public:
rFFT::rFFT( SLArrayIndex_t FFTLength,
const enum SLWindow_t WindowType = SIGLIB_RECTANGLE,
bool createInternalArrays = true, // internal working arrays generated within the constructor if true
QObject *parent = NULL ); // otherwise, arrays should be passed as arguments
rFFT::~rFFT();
void doFFT( SLData_t *pReal, // pReal is also input array, will be overwritten!
SLData_t *pImag ); // works with both versions of rFFT
void doFFT( SLData_t *pInput ); // works only with an instance of rFFT having internal arrays, pInput is preserved!
.....
};
|
the use of the class is as follows:
Version with 'internal arrays':
1 2 3 4 5
|
// declare and allocate memory for pReal, pImag, pInput
// write some data into pReal and pInput
rFFT myFFTWithInternalArrays( FFT_LENGTH, SIGLIB_HANNING ); // true by default -> generates internal arrays
myFFTWithInternalArrays.doFFT( pReal, pImag ); // OK
myFFTWithInternalArrays.doFFT( pInput ); // OK
|
Version with 'external arrays':
1 2 3
|
rFFT myFFTWithOUTInternalArrays( FFT_LENGTH, SIGLIB_HANNING, false ); // false -> no internal arrays
myFFTWithOUTInternalArrays.doFFT( pReal, pImag ); // OK
myFFTWithOUTInternalArrays.doFFT( pInput ); // LEADS TO ACCESS VIOLATION DURING RUNTIME
|
The method void doFFT( SLData_t *pInput ) can only call an instance of rFFT having internal arrays.
Unfortunately, the error is detected at runtime.
I have inserted an error message within the method 'rFFT::doFFT( SLData_t* pInput )':
1 2
|
if ( ! mHasInternalArrays )
qDebug() << " === ERROR: use of 'rFFT::doFFT( SLData_t *pInput )' only allowed with rFFT having internal arrays, leads to assertion error! ===" ;
|
but I would prefer to have the error message already during compile time.
I did'nt find a solution, do somebody see one?
I thank you for your valuable time
Alain